Opened 15 years ago

Closed 10 years 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 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Julien Phalip, 14 years ago

Severity: Normal
Type: Cleanup/optimization

comment:3 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:4 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:5 by Collin Anderson, 10 years ago

Cc: cmawebsite@… added

This select will likely become necessary for #6707

comment:6 by Collin Anderson, 10 years ago

Resolution: wontfix
Status: newclosed

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