Django should do m2m deletes in a single query when possible
|Reported by:||jdunck||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.4|
|Cc:||django@…||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
As Anssi notes there:
To me it seems there is no reason to do two queries in delete if the following conditions hold: - there are no signals sent for the deleted objects - the delete does not cascade further (actually you don't need to collect even in this case - you can do the cascade query completely in the DB without fetching the IDs first).
I think a good first-cut is auto-created intermediate table and no signals attached for that model.
Change History (13)
comment:7 Changed 19 months ago by Anssi Kääriäinen <akaariai@…>
- Resolution set to fixed
- Status changed from new to closed