Opened 7 years ago

Closed 7 years ago

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

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

Changed 7 years ago by Alex

moved the logic into add_aggregate to mirror add_filter

Changed 7 years ago by Alex

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 7 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

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

comment:2 Changed 2 years ago by akaariai

  • Component changed from ORM aggregation to Database layer (models, ORM)
Note: See TracTickets for help on using tickets.
Back to Top