-> To get the active sessions use this query.
cmd:select usename, pid, datname from pg_stat_activity;
-> Now we can see the active sessions if we want to close all the connections to the particular database then use the cmd.
cmd:
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = ‘test_db’;
-> After the execution of this cmd we need to restart the application server to activate the session.
Kill the sessions in postgresql
Related Posts
Vi editor in Linux
Its a visual editor by default installed in every linux system. The next version of vi is vim. The vi editor tool is an interactive tool as it displays changes…
Monitoring in Postgresql
In normal PostgreSQL operation, tuples that are deleted or obsoleted by an update are not physically removed from their table. They remain present until a VACUUM is done. Therefore it’s necessary to do VACUUM periodically, especially…