Deleting a project results in a large number of SQL requests that could be optimized
When deleting a big project, gitlab produces a very large amount of SQL Statements like these:
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25079]]
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25080]]
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25081]]
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25082]]
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25083]]
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25084]]
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25085]]
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25086]]
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25087]]
SQL (1.0ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25088]]
SQL (1.1ms) DELETE FROM "notes" WHERE "notes"."id" = $1 [["id", 25089]]
This could be done in a single SQL statement.
DELETE FROM "notes" WHERE "notes"."id" in 25087,25088,25089 [....]
\cc @dzaporozhets Can you please take a look? It's another performance issue. I tested this with the linux mainline kernel.
Deleting it took several minutes because of the huge amount of SQL Statements.