psql -d appdb -c "SELECT query, total_exec_time FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;"

Category: Databases & SQL

psql -d appdb -c "SELECT query, total_exec_time FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;"

Rank the slowest statements

Lists the ten statements that consumed the most server time; total_exec_time accumulates since the extension loaded. The standard first step in a query-tuning project. Requires the pg_stat_statements extension.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.