Opened 7 years ago

Closed 3 years ago

#8769 closed Cleanup/optimization (fixed)

Slightly over-aggressive join promotion in SQL for ordering

Reported by: mtredinnick Owned by: mtredinnick
Component: Database layer (models, ORM) Version: master
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

Right now, we promote any table join used in the ordering portion to an outer join if it potentially contains NULL values (the corresponding Django field has null=True). There are some cases where this is unnecessary. If we already used that join in the filter statements and didn't make it an outer join at that point, it's because we are already filtering out the null values, so an inner join still won't lose any results in the ordering.

Thus, we should only promote joins for ordering if we needed to add that join for the ordering (this means self.alias_refcount[...] == 1, or something else that's easily detectable).

Noting this so I don't forget. Don't want to introduce new bugs at the moment and it's a bit of an edge case, so it can wait until post-1.0.

Change History (5)

comment:1 Changed 7 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by lukeplant

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:3 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:4 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:5 Changed 3 years ago by akaariai

  • Resolution set to fixed
  • Status changed from assigned to closed

This one seems to be fixed in: 8c72aa237918e31a525022f72b22cac75451af86

Note: See TracTickets for help on using tickets.
Back to Top