Opened 6 years ago

Closed 5 weeks 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

Description

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)
etc...

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

Change History (6)

comment:1 Changed 6 years ago by Alex

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

comment:2 Changed 4 years ago by julien

  • 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 5 weeks ago by collinanderson

  • Cc cmawebsite@… added

This select will likely become necessary for #6707

comment:6 Changed 5 weeks 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