Checking active sessions
Using this recipe, we will get all the active sessions from a PostgreSQL instance, which are utilizing the server resources.
Getting ready
Like other database management systems, PostgreSQL is also providing a set of catalog tables and views, which will help us to retrieve the current instance status. In this recipe, we will be discussing a catalog view, which every DBA/developer queries very frequently.
How to do it...
Connect to your database using the psql client as a superuser and check the
track_activities
parameter status:postgres=# SHOW track_activities; track_activities ------------------ on (1 row)
Initiate the
pgbench
test as follows:$ pgbench -i; pgbench -c 4 -T 100 creating tables... 100000 of 100000 tuples (100%) done (elapsed 0.17 s, remaining 0.00 s) vacuum... set primary keys... ...