O'Reilly logo

PostgreSQL High Performance Cookbook by Dinesh Kumar, Chitij Chauhan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  1. 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)
    
  2. Initiate the pgbench test as follows:
     $ pgbench -i; pgbench -c 4 -T 100 creating tables... 100000 of 100000 tuples ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required