#34462: Deletions in admin panel create N + 1 queries
-------------------------------------+-------------------------------------
               Reporter:  Mike       |          Owner:  nobody
  Lissner                            |
                   Type:             |         Status:  new
  Cleanup/optimization               |
              Component:             |        Version:  3.2
  contrib.admin                      |
               Severity:  Normal     |       Keywords:  performance
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Sentry has a new feature that identifies when your app has an N+1 query:

 https://docs.sentry.io/product/issues/issue-details/performance-issues/n
 -one-queries/

 (I'll pause here to note my love of Sentry.)

 This new feature just identified that when you delete multiple items from
 the admin panel, Django does an N+1 query for each of them, so if you
 delete 100 items, as I just did, it generates 100 queries to your
 database. The queries are small, but this isn't great.

 According to Sentry, the queries it generates are of the form:


 {{{
 INSERT INTO "django_admin_log" ("action_time", "user_id",
 "content_type_id", "object_id", "object_repr", "action_flag",
 "change_message") VALUES (%s, %s, %s, %s, %s, %s, %s) RETURNING
 "django_admin_log"."id"
 }}}

 I think a bulk_insert would fix this, right?

 I don't have time to tackle this, but I thought I'd at least report it. Do
 we care?

 I can share the Sentry issue with anybody that wants to tackle this. So we
 can find it later, it's BIGCASES2-V in our system.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34462>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018752b3363c-3c0d5a34-d9e3-4919-8f5c-2b9bd33b33c5-000000%40eu-central-1.amazonses.com.

Reply via email to