﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34462	Deletions in admin panel create N + 1 queries	Mike Lissner	Akash Kumar Sen	"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."	Cleanup/optimization	closed	contrib.admin	3.2	Normal	fixed	performance	David Wobrock	Ready for checkin	1	0	0	0	1	0
