pg_stat_activity
CautionPostgres sessions
SELECT pid, state, query FROM pg_stat_activity;
Postgres' processlist. Long 'idle in transaction' sessions are the classic lock holders to terminate.
Examples
SELECT pg_terminate_backend(12345);Kill a problem session
Syntax
SELECT * FROM pg_stat_activity; / SELECT pg_terminate_backend(pid);
Before you run it
Termination aborts their work.
Related commands
- Show running queriesShow running queries
- Kill query / sessionKill a query/session
The same reference, with no signal at all
Every command on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).
Get it free on the App Store