A monitoring utility similar to the Unix top utility

pg_top is a PostgreSQL interactive monitoring utility, similar to the Unix top utility, providing a dynamically updated view of activity within a PostgreSQL database.

Note that there is a similar utility named pgtop.


From source

pg_top requires cmake, and if installing on Linux, the libbsd compatibility library (on CentOS et al: libbsd-devel; Debian et al: libbsd-dev).

$ cmake CMakeLists.txt
-- The C compiler identification is GNU 4.8.5
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pgpedia/devel/postgres/pg_top

$ make
Scanning dependencies of target pg_top
[  7%] Building C object CMakeFiles/pg_top.dir/color.c.o
[ 46%] Building C object CMakeFiles/pg_top.dir/pg_top.c.o
[ 69%] Building C object CMakeFiles/pg_top.dir/machine/m_linux.c.o
Linking C executable pg_top
Install the project...
-- Install configuration: ""
-- Installing: /home/pgpedia/bin/pg_top
-- Installing: /home/pgpedia/share/man/man1/pg_top.1

Release history

This is a summary of the major point releases; for a full and detailed list of releases, see the pg_top release page and the release notes.

Note: the source code appears to start with coding release 3.6.1, with the earliest commit (bc66647b) giving the impression it was imported from a Subversion repository (albeit without retaining any commit history).


Execute with e.g. pg_top -d 'host=localhost dbname=postgres user=postgres':

last pid: 14011;  load avg:  1.68,  2.01,  2.05;       up 27+20:39:01                                   10:11:52
5 processes: 4 other background task(s), 1 active
CPU states: 45.7% user,  0.0% nice,  4.1% system, 49.5% idle,  0.6% iowait
Memory: 14G used, 237M free, 0K shared, 37M buffers, 1862M cached
Swap: 8284M used, 8100M free, 551M cached, 0K in, 0K out

14012 postgres 2278M 7868K active   0:00   0:00   0.0     8 postgres: postgres postgres idle
14356          2276M  220K          0:00   0:00   0.0     0 postgres: background writer        
14355          2276M   30M          0:00   0:00   0.0     0 postgres: checkpointer             
14353          2276M   32M          0:00   0:00   0.0     0 postgres: startup   recovering 0000000100000003000000B0
 5676          2285M 2112K          0:00   0:00   0.0     0 postgres: walreceiver   streaming 3/B014B4F8


Monitoring, Utility program

See also

pg_stat_activity, pg_activity, pgtop