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 , 18 years ago
Summary: | related data injection for related managers → related data injection for related managers to reduce number of queries |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 18 years ago
comment:3 by , 17 years ago
Cc: | added |
---|
comment:4 by , 17 years ago
Reporter: | changed from | to
---|
comment:5 by , 16 years ago
Component: | Metasystem → Database wrapper |
---|
comment:6 by , 16 years ago
Cc: | removed |
---|
comment:7 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:10 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
#18177 was a duplicate and it was fixed.
Note:
See TracTickets
for help on using tickets.
i just noticed #17
i think they both adress a semilar problem