Opened 18 years ago

Closed 12 years ago

#3470 closed New feature (fixed)

related data injection for related managers to reduce number of queries

Reported by: Ronny Pfannschmidt Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

it would be nice, of querysets injected objects where used as query parameters to the result set

example using the polls app from the tutorial

from polls.models import *
from django.db import connection
Poll.objects.get(id=1).choice_set.all()[0].poll

results in 3 queries, since the related manager wont pass the orginal poll object to the instances of the choices

after this code connection.queries is

[
 {'time': '0.000', 
  'sql': 'SELECT "polls_poll"."id","polls_poll"."question","polls_poll"."pub_date" FROM "polls_poll" WHERE ("polls_poll"."id" = 1)'},       
 {'time': '0.000', 
  'sql': 'SELECT "polls_choice"."id","polls_choice"."poll_id","polls_choice"."choice","polls_choice"."votes" FROM "polls_choice" WHERE ("polls_choice"."poll_id" = 1) LIMIT 1 '}, 
 {'time': '0.000', 
  'sql': 'SELECT "polls_poll"."id","polls_poll"."question","polls_poll"."pub_date" FROM "polls_poll" WHERE ("polls_poll"."id" = 1)'}]

the same query twice just cause a python object doesn't get passed

Change History (10)

comment:1 by Simon G. <dev@…>, 18 years ago

Summary: related data injection for related managersrelated data injection for related managers to reduce number of queries
Triage Stage: UnreviewedAccepted

comment:2 by Ronny Pfannschmidt <ronny.pfannschmidt@…>, 18 years ago

i just noticed #17
i think they both adress a semilar problem

comment:3 by (removed), 17 years ago

Cc: ferringb@… added

comment:4 by Jacob, 17 years ago

Reporter: changed from Ronny Pfannschmidt <ronny.pfannschmidt@…> to Ronny Pfannschmidt

comment:5 by Adrian Holovaty, 16 years ago

Component: MetasystemDatabase wrapper

comment:6 by (removed), 16 years ago

Cc: ferringb@… removed

comment:7 by Łukasz Rekucki, 14 years ago

Severity: Normal
Type: New feature

comment:8 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:9 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:10 by Aymeric Augustin, 12 years ago

Resolution: fixed
Status: newclosed

#18177 was a duplicate and it was fixed.

Note: See TracTickets for help on using tickets.
Back to Top