On Saturday, November 24, 2012 8:03:06 AM UTC+1, Peter of the Norse wrote:

> On Nov 21, 2012, at 3:53 AM, ?manu* wrote: 
>
> > Suppose I have a queryset qs. For paginating purposes I need to do 
> something like: 
> > 
> > count = qs.count() 
> > qs = qs[0:100] 
> > 
> > Unfortunately this executes the query twice, which I don't want. 
>
> Are you sure? This is such a common pattern that I suspect that it’s not 
> slower than making it into one query. I ran some tests on the slowest query 
> I have, and the two statements were faster than trying to combine them. 0.2 
> + 1.5 sec vs. 1.9 sec. 
>

You are right! (thanks also to Javier). It is not clear to me how it is 
possible but effectively it seems that the two queries are not slower than 
a single one...

Thank you also for the other answers.

E.
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/zylmsQNJeDoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to