3 ms·
You can use the .psqlrc for this purpose, though I suppose you could also real that in via a file on demand, too. You make entries something like: \set show
by sbuttgereit 6y ago
You can use the .psqlrc for this purpose, though I suppose you could also real that in via a file on demand, too. You make entries something like:
\set show_slow_queries
'SELECT
(total_time / 1000 / 60) as total_minutes,
(total_time/calls) as average_time, query
FROM pg_stat_statements
ORDER BY 1 DESC
LIMIT 100;'
(got from https://www.craigkerstiens.com/2013/02/21/more-out-of-psql/ https://www.craigkerstiens.com/2013/02/21/more-out-of-psql/)
and then later at the command prompt you access it as; ":show_slow_queries".
I have a few system queries like this in my .psqlrc file, but I don't do much which this feature often truth be told. I have a pretty strong knowledge of the database schema I work with, I do a lot of work on systems I don't regularly control so its not dependably available, and readline history suffices for more immediate needs.