#36248: Bulk deletion of model referred to by a SET_NULL key can exceed 
parameter
limit
-------------------------------------+-------------------------------------
     Reporter:  bobince              |                    Owner:  bobince
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  5.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by bobince):

 > I guess I could scrape the SQL string for number of integers but this
 feels pretty fragile.

 Have tried something similar to this (counting commas in ‘IN’ clauses) and
 actually maybe it's not thaaat bad. I've written worse.

 Now I have a test that's only counting parameters not queries, I tried
 using the existing test model ‘R’ instead of making a new one. This turned
 up an delightful wrinkle in that the fast-delete path can also ‘OR’
 together multiple querysets, this time when there are multiple references
 on one model to rows being deleted. For example if Article.author and
 Article.editor are ForeignKeys to Person with on_delete=CASCADE, and 500
 Person rows are deleted, deletion will put together a query like `DELETE
 FROM article WHERE author IN (...500 params...) OR editor IN (...another
 500 params...)` and if you have a DBMS with a param limit of 999 you're
 now sad.

 So, er, back to simpler relations for now. I don't think there's a
 straightforward fix to this — it would take a more wide-ranging rethink of
 how param limits impact batch sizes and I don't really have a good idea
 what that would look like. Ugh, I wish param limits would go away
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36248#comment:6>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/010701958c57cc78-b237ff84-f1d9-46d4-8593-de987d08efaa-000000%40eu-central-1.amazonses.com.

Reply via email to