Postgres DBA · Lesson 12

Kill the sessions in postgresql

-> 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)…

connected · blinksql_demo

-> To get the active sessions use this query.
cmd:select usename, pid, datname from pg_stat_activity;
to know the active sessions
-> 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’;

kill the sessions
-> After the execution of this cmd we need to restart the application server to activate the session.

Practice — AI-generated for this lesson

Write a query that shows each order status and how many orders have it — but only statuses with more than 1 order.