Sample Header Ad - 728x90

Where to get the error/info logs of what happens when committing several statements?

2 votes
2 answers
817 views
I had a problem with an index missing on a table and the only way I had to gather clues was this way: BEGIN TRANSACTION; -- OVER 100 DELETES COMMIT; In DBeaver, I selected only the first line and the subsequent deletes, executed that. Then, selected the commit line, executed that and waited until I felt that this is taking too long. Then DBeaver gave me this message, when I canceled the transaction: SQL Error : ERROR: canceling statement due to user request Where: SQL statement "SELECT 1 FROM ONLY "schema"."table" x WHERE $1 OPERATOR(pg_catalog.=) "id_model" AND $2 OPERATOR(pg_catalog.=) "id_property1" AND $3 OPERATOR(pg_catalog.=) "id_property2" FOR KEY SHARE OF x" id_model is the WHERE clause for all the DELETEs in question. The query mentioned in the message is definitely not code written by me, anywhere in any function/procedure/trigger I can think of. I took from this that a missing index on table with columns id_property1 and id_property2 was the problem, and apparently it was. Are there any logs explaining what is happening "under the hood" when the server is processing several statements queued in the transaction where I could have more easily found that statement? There are several delete foreign key constraints configured in the model, so I guess when indexes are missing, the server is taking a while to find the correct way around?
Asked by Francis Ducharme (123 rep)
Nov 1, 2023, 09:11 PM
Last activity: Nov 2, 2023, 04:13 PM