psql -d appdb -c "SELECT pid, query FROM pg_stat_activity WHERE state = 'active';"
Show active query process IDs
Narrows pg_stat_activity to the process ID and SQL text of running queries, compact enough to eyeball during an incident. Combine with SELECT pg_terminate_backend(pid) to kill the offender.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.