Turn on pg_stat_statements before you need it
The first question in every database incident is "which query", and pg_stat_statements is the only thing that answers it from history rather than from the moment you happened to look.
SELECT calls, mean_exec_time, query
FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;It costs a few percent. The afternoon you spend without it costs more.
postgresqlobservability