psql -d appdb -c "SELECT * FROM pg_stat_activity WHERE state = 'active';"
Show running queries
pg_stat_activity is the live view of every backend; filtering on state = 'active' isolates queries currently executing. Columns include pid, usename, query, and how long the query has run. The starting point for almost any stuck-database investigation.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.