Opened 16 years ago

Closed 16 years ago

Last modified 12 years ago

#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)

aggregation-m2m-opt.diff (3.7 KB ) - added by Alex Gaynor 16 years ago.
In defiance of all logic and reason I seem to have actually accomplished something within setup_joins :O
aggregation-m2m-opt.2.diff (1.6 KB ) - added by Alex Gaynor 16 years ago.
moved the logic into add_aggregate to mirror add_filter
aggregation-m2m-opt.3.diff (2.8 KB ) - added by Alex Gaynor 16 years ago.
added a comment describing the optimization and a test to show that it works, the test is slightly fragile but should be ok

Download all attachments as: .zip

Change History (5)

by Alex Gaynor, 16 years ago

Attachment: aggregation-m2m-opt.diff added

In defiance of all logic and reason I seem to have actually accomplished something within setup_joins :O

by Alex Gaynor, 16 years ago

Attachment: aggregation-m2m-opt.2.diff added

moved the logic into add_aggregate to mirror add_filter

by Alex Gaynor, 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 Russell Keith-Magee, 16 years ago

Resolution: fixed
Status: newclosed

Fixed in github branch, commit ae196bf779c20c5559db4b637f95cfd1cdb8af3f. Thanks to Alex Gaynor for his help on this.

comment:2 by Anssi Kääriäinen, 12 years ago

Component: ORM aggregationDatabase layer (models, ORM)
Note: See TracTickets for help on using tickets.
Back to Top