#30533: Delete cascade can break postgresql database: too large 'DELETE FROM a
WHERE a.b_id IN (...)'
-------------------------------------+-------------------------------------
Reporter: Thomas Riccardi | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: queryset delete | Triage Stage:
cascade batch bulk_batch_size | Unreviewed
postgresql crash |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Thomas Riccardi):
Replying to [comment:1 felixxm]:
> Thanks for the report. Do you know any source that describes the max
number of parameters for PostgreSQL? (e.g. 64k is specified in db docs on
Oracle).
I think there is no hardcoded limits in postgresql; what I think probably
happened is a high memory allocation that resulted in an OOMKill on the
connection process on the db side: with more RAM the query could probably
work.
The queries pattern in this scenario is:
- get all B objects to delete: SELECT
- delete all A related objects: the unbound DELETE IN that crashes
- delete all B objects: DELETE IN with batch of 100
It would make sense to have the same size for the 2 DELETE IN, but 100 is
really small for DELETEs (the result size is constant, not proportional to
the number of deleted objects): maybe add another constant for DELETE:
`GET_ITERATOR_CHUNK_SIZE` should be for get (where the result size is
proportional to the number of objects), with a much higher value; this
could be part of the fix for this ticket?
--
Ticket URL: <https://code.djangoproject.com/ticket/30533#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/073.bfbcaa99b3f16cba454b43f8f4dfdeaa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.