Opened 8 years ago

Closed 8 years ago

Last modified 4 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: UI/UX:

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 8 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 8 years ago.
moved the logic into add_aggregate to mirror add_filter
aggregation-m2m-opt.3.diff (2.8 KB) - added by Alex Gaynor 8 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)

Changed 8 years ago by Alex Gaynor

Attachment: aggregation-m2m-opt.diff added

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

Changed 8 years ago by Alex Gaynor

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

moved the logic into add_aggregate to mirror add_filter

Changed 8 years ago by Alex Gaynor

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 Changed 8 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

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

comment:2 Changed 4 years ago by Anssi Kääriäinen

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