PostgreSQL Session Management

  • Identifying current connections/queries

  SELECT * from pg_stat_activity;

  • To stop a query

  SELECT pg_cancel_backend(procpid);

  • To kill the connection

  SELECT pg_terminate_backend(procpid);



  • Run (select * from pg_stat_activity) in pgAdmin to get a clear table structure to identify procpid numbers
  • If the item you have terminated remains in the list  (from select * from pg_stat_activity) then terminate other connections to the same table first

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s