Opened 7 years ago

Closed 19 months ago

#11280 closed Cleanup/optimization (wontfix)

model.m2m = [pk, list] Performs unnecessary SELECT

Reported by: Zulq Alam <me@…> Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Normal Keywords: m2m, bulk
Cc: cmawebsite@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When assigning a collection to an m2m relationship using a list of PKs an unnecessary SELECT is performed.

DELETE FROM model_m2m WHERE model_pk = %s
SELECT FROM model_m2m WHERE model_pk = %s AND m2m_pk IN (%s, %s, %s, ...)
INSERT INTO model_m2m (model_pk, m2m_pk) VALUES (%s, %s)
INSERT INTO model_m2m (model_pk, m2m_pk) VALUES (%s, %s)

The DELETE will remove any rows the SELECT might have found.

Change History (6)

comment:1 Changed 7 years ago by Alex

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

comment:2 Changed 5 years ago by julien

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

comment:3 Changed 5 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:4 Changed 5 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:5 Changed 19 months ago by collinanderson

  • Cc cmawebsite@… added

This select will likely become necessary for #6707

comment:6 Changed 19 months ago by collinanderson

  • Resolution set to wontfix
  • Status changed from new to closed

To be clear: if we fix #6707 (which we should do), we shouldn't fix this ticket, so I think we should close in the meantime. Feel free to reopen if anyone thinks we should fix this anyway in the meantime.

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