Re: len() vs count
count() does a sql count statement, while len() loads all rows from
the database and returns the array length of the results.
count() is much faster and better to use if you can conditionally
avoid loading all results.
On Jun 15, 6:17 am, Lee Hinde <leehi...@gmail.com> wrote:
> This started off as a pagination question, but then I realized it was
> a different issue:
>
> Given:http://dpaste.com/hold/207217/
>
> why would len(n) be different than n.count()
>
> In my case, the len result is correct, but Paginator tries count first
> (and uses that value).
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home