DBA Hub

📋Steps in this guide1/1

Kill all session of a user in postgres

-- Here we want to kill all session of the user postgres

postgresql configurationintermediate
by PostgreSQL
16 views
1

Kill all session of a user in postgres

-- List all the session of that user. dbaclass# select datname as database, pid as pid, usename as username, application_name , client_addr, query FROM pg_stat_activity where username='postgres'; -- Kill all the session of user postgres.

Code/Command (click line numbers to comment):

1
2
3
-- Here we want to kill all session of the user postgres
dbaclass#
select pg_terminate_backend(pid) from pg_stat_activity where usename='postgres';

Comments (0)

Please to add comments

No comments yet. Be the first to comment!