baptisteArno
06/24/2022, 5:30 AMsql
begin;
explain (analyze,buffers,timing)
DELETE FROM "public"."Result" WHERE "public"."Result"."id" IN ('cl1iagqm0003109l8pp19c020','cl1ngg8yt066909mp1jbcjf2g','cl1prkyhb107609minrghucq8','cl2uvt3jo064409l7voketuxg','cl1xy5oby075409l42s25q8sc');
rollback;
Is logging:
Delete on "Result" (cost=0.42..26.51 rows=0 width=0) (actual time=4.245..4.246 rows=0 loops=1)
Buffers: shared hit=28 read=9 dirtied=4
-> Index Scan using "Result_pkey" on "Result" (cost=0.42..26.51 rows=5 width=6) (actual time=0.058..4.113 rows=5 loops=1)
Index Cond: (id = ANY ('{cl1iagqm0003109l8pp19c020,cl1ngg8yt066909mp1jbcjf2g,cl1prkyhb107609minrghucq8,cl2uvt3jo064409l7voketuxg,cl1xy5oby075409l42s25q8sc}'::text[]))
Buffers: shared hit=14 read=9
Planning:
Buffers: shared hit=56
Planning Time: 0.425 ms
Trigger for constraint Answer_resultId_fkey: time=6.694 calls=5
Trigger for constraint Log_resultId_fkey: time=632.656 calls=5
Execution Time: 643.656 ms
(11 rows)
So cascades are triggered for Answer and Log but for some reason, the Log trigger takes a ton of time but there are no Logs to delete in this case
Any idea how I can optimize that?