Re: unnecessary select

35 views
Skip to first unread message

Jeremy Lainé

unread,
Jul 23, 2014, 7:45:57 AM7/23/14
to otop...@gmail.com, qdj...@googlegroups.com

Can you please post the entire code as what you sent should trigger no database queries at all: you are not iterating on the results.

Thanks,
Jeremy

On 23 Jul 2014 12:45, otop...@gmail.com wrote:
Hi,
When I create query set and then do filter() there are two selects in debug output - first one selects all from table and second is that filter.

QDjangoQuerySet<Table> table;
matched
= table.filter(QDjangoWhere("other_id", QDjangoWhere::Equals, otherId)).selectRelated().limit(20,80);

Produces:


SELECT `table`.`id`, `table`.`other_id` FROM `table`

SELECT `table`.`id`, `table`.`other_id`, T0.`id`, T0.`name` FROM `table` INNER JOIN `other` T0 ON T0.`id` = `table`.`other_id` WHERE `table`.`other_id` = ? LIMIT 80 OFFSET 20


How should I use the query set to make just the second select? - the first is unnecessary - I am going to have lot of items in table so it would kill the efficiency gained with limit.
Thanks





--
You received this message because you are subscribed to the Google Groups "QDjango" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qdjango+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

otop...@gmail.com

unread,
Jul 23, 2014, 10:55:32 AM7/23/14
to qdj...@googlegroups.com, otop...@gmail.com
Ugh I found out what was the problem..
I was printing the size like this:

QDjangoQuerySet<Asset> assets;
qDebug
() << assets.size();

Then I thought that the select was made in constructor. Appologies.

Dňa streda, 23. júla 2014 13:45:57 UTC+2 Jeremy Lainé napísal(-a):
Reply all
Reply to author
Forward
0 new messages