Hi,
As others have aptly told you, Querysets are executed in a lazy
fashion. I would like to add that Django resolves the array slicing
syntax (e.g. queryset[:5]) to the LIMIT clause in SQL. So, when your
Poll Queryset is executed (lazily, of course), your DB will send only
the 5 rows of data ove
Thanx all for explanations :)
--~--~-~--~~~---~--~~
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 [EMA
On Jan 22, 2008 8:16 AM, code_berzerker <[EMAIL PROTECTED]> wrote:
> this gives 5 Poll objects. I wonder if this is efficient way of
> getting them? Does django get all rows first and then sort it and then
> slice it to get only 5? Or is it optimized somehow. The question is if
> its simplified fo
On Tuesday 22 January 2008 16:16:34 code_berzerker wrote:
> theres line of code in tutorial:
>
> Poll.objects.all().order_by('-pub_date')[:5]
>
> this gives 5 Poll objects. I wonder if this is efficient way of
> getting them? Does django get all rows first and then sort it and then
> slice it to g
This is the right way to do so. Querysets are lazy. Only the rows
needed will be fetched in this example.
code_berzerker wrote:
> theres line of code in tutorial:
>
> Poll.objects.all().order_by('-pub_date')[:5]
>
> this gives 5 Poll objects. I wonder if this is efficient way of
> getting them? D
theres line of code in tutorial:
Poll.objects.all().order_by('-pub_date')[:5]
this gives 5 Poll objects. I wonder if this is efficient way of
getting them? Does django get all rows first and then sort it and then
slice it to get only 5? Or is it optimized somehow. The question is if
its simplifi
6 matches
Mail list logo