There should be no problem at all (taken from the paginator
source
http://code.djangoproject.com/bro
wser/django/trunk/django/core/paginator.py#L39):
An queryset like Category.objects.all() would result in (see
above
link):
>>> from django.db import connection
>>> Category.objects.all()[5:10]
[<Category: Fleisch>, <Category: Vorspeise,
Snack>, <Category:
Aufstrich>, <Category: Suppe>, <Category:
Tip>]
which translates into the following sql:
>>> connection.queries[-1]
{'time': '0.007', 'sql': u'SELECT
`cookbook_category`.`id`,`cookbook_category`.`category`
FROM
`cookbook_category` LIMIT 5,5 '}
As you can see limit is used (as the queryset is not
executed and
sliced then...) and not all objects get fetched.
Hope this helps,
Florian Apolloner
On Aug 31, 9:11 pm, Sebastian Macias <sebast... sebastianmacias.com>
wrote:
> I'm building an app that requires pagination. I looked
at the
> official
> pagination documentation I found at:
>
> http://www.djangoproject.com/documentation/models/p
agination/
>
> I followed the tutorial and basically: paginator =
> ObjectPaginator(Article.objects.all(), 5) is where all
the "magic"
> happens.
>
> What I'm concerned about is that Article.objects.all()
will return a
> query_set with all of the records. If I have millions
of records it
> means the returned query_set will be huge and I'm
affraid performance
> will be poor in and very busy site.
>
> Should I be concerned about this? What are your
thoughs?
>
> Thanks,
>
> Sebastian Macias
--~--~---------~--~----~------------~-------~--~----~
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 htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|