This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Viewing current PostgreSQL queries | |
-- source: http://chrismiles.info/systemsadmin/databases/articles/viewing-current-postgresql-queries/ | |
SELECT datname,pid,query,query_start FROM pg_stat_activity ORDER BY query_start ASC; | |
-- top-like view of current queries, grouped by how many of the same query are running at that instant and the usernames belonging to each connection. | |
SELECT count(*) as cnt, usename, current_query FROM pg_stat_activity GROUP BY usename,current_query ORDER BY cnt DESC; | |
-- List databases creation dates | |
SELECT (pg_stat_file('base/'||oid ||'/PG_VERSION')).modification, datname FROM pg_database ORDER BY modification; | |
SELECT (pg_stat_file('base/'||oid ||'/PG_VERSION')).modification, datname FROM pg_database ORDER BY datname; |