I'm using Postgres 9.6 in Ubuntu.
With many tables and many foreign keys, when I delete certain data it generates the respective commands implicitly to clean up the foreign relations.
This can be "seen" when a long running DELETE statement is interrupted with e.g. CTRL-c it shows which "background" statement was running.
Is there way to see all the statements which are generated/executed in the background? The log_statement configuration does not show them either.
There's no built-in way, but it's possible with an ExecutorStart_hook.
The auto_explain contrib module can trace "nested" statements. See auto_explain.log_nested_statements. I'm not sure if it ignores FK checks or considers them; the nested statements feature is mainly used for things like PL/PgSQL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With