And no, I'm not using any plugins, except of course have DEBUG=True.
On Mar 12, 10:59 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, Mar 12, 2009 at 11:24 PM, adrian <adrian...@gmail.com> wrote:
>
> > I have a view that does not evaluate a queryset, it just adds filters
> > and order_by and then
> > passes it to Paginator (set to 50 per page) and the result is passed
> > to the template. The following SQL is generated (with some fields
> > omitted for clarity). I'm using Django 1.0.2 and MySQL 5.1.
>
> > SELECT `lister_importedsighting`.`id`,
> > `lister_importedsighting`.`user_id`,
> > `lister_importedsighting`.`date_added`,
> > `lister_importedsighting`.`active`,
> > `lister_importedsighting`.`tax_order` FROM `lister_importedsighting`
> > WHERE (`lister_importedsighting`.`user_id` = 1 AND
> > `lister_importedsighting`.`birdlist_area` = ABA ) ORDER BY
> > `lister_importedsighting`.`species_name` ASC LIMIT 50
>
> > SELECT `lister_importedsighting`.`id`,
> > `lister_importedsighting`.`user_id`,
> > `lister_importedsighting`.`date_added`,
> > `lister_importedsighting`.`active`,
> > `lister_importedsighting`.`tax_order` FROM `lister_importedsighting`
> > WHERE (`lister_importedsighting`.`user_id` = 1 AND
> > `lister_importedsighting`.`birdlist_area` = ABA ) LIMIT 21
>
> > SELECT `lister_importedsighting`.`id`,
> > `lister_importedsighting`.`user_id`,
> > `lister_importedsighting`.`date_added`,
> > `lister_importedsighting`.`active`,
> > `lister_importedsighting`.`tax_order` FROM `lister_importedsighting`
> > WHERE (`lister_importedsighting`.`user_id` = 1 AND
> > `lister_importedsighting`.`birdlist_area` = ABA ) ORDER BY
> > `lister_importedsighting`.`species_name` ASC LIMIT 21
>
> > SELECT `lister_importedsighting`.`id`,
> > `lister_importedsighting`.`user_id`,
> > `lister_importedsighting`.`date_added`,
> > `lister_importedsighting`.`active`,
> > `lister_importedsighting`.`tax_order` FROM `lister_importedsighting`
> > WHERE (`lister_importedsighting`.`user_id` = 1 AND
> > `lister_importedsighting`.`birdlist_area` = ABA ) ORDER BY
> > `lister_importedsighting`.`species_name` ASC LIMIT 21
>
> > My question is why are the last 3 queries present, and where did limit
> > 21 come from, a number not present in my view at all?
>
> They're coming from some code attempting to print or take the repr of the
> queryset. See:
>
> http://groups.google.com/group/django-users/msg/e20328499c793e41
>
> (It looks like there may be more than one queryset variable involved here --
> one of those LIMIT 21 queries doesn't have an order by clause.)
>
> > It matters because in some cases my SQL queries are much more
> > expensive than this, and they
> > run for every page if Paginated.
>
> If it's not immediately clear to you where these calls to repr are coming
> from it might be worth trying to track them down. Years ago querysets in a
> template context would get evaluated as a side-effect of attempting to
> access a non-existant template variable
> (seehttp://groups.google.com/group/django-users/browse_thread/thread/82df...)
> but that was fixed a long time ago. It looks like something, though, is
> doing similar with the querysets you are working with here. Are you running
> with any debugging plugins or other code that might be doing processing on
> your template context?
>
> Karen
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---