#9870 closed (fixed)
When querying aross a many to many field if the target is the primary key only join to the intermediary table
Reported by: | Alex Gaynor | Owned by: | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If we are querying across a many to many field and we only want to access the primary key of the related data we can reduce our joins by only going to the intermediary table.
This is being filed against the external aggregation branch.
Attachments (3)
Change History (5)
by , 16 years ago
Attachment: | aggregation-m2m-opt.diff added |
---|
by , 16 years ago
Attachment: | aggregation-m2m-opt.2.diff added |
---|
moved the logic into add_aggregate to mirror add_filter
by , 16 years ago
Attachment: | aggregation-m2m-opt.3.diff added |
---|
added a comment describing the optimization and a test to show that it works, the test is slightly fragile but should be ok
comment:1 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in github branch, commit ae196bf779c20c5559db4b637f95cfd1cdb8af3f. Thanks to Alex Gaynor for his help on this.
comment:2 by , 12 years ago
Component: | ORM aggregation → Database layer (models, ORM) |
---|
In defiance of all logic and reason I seem to have actually accomplished something within setup_joins :O