Common
Postgres CheatSheet
15. January 2020
0

Show open connections

apt install ptop #debian
su postgres
pg_top

This will show a live list of open connections with some interesting details:

last pid:  3617;  load avg:  0.10,  0.11,  0.09;       up 0+15:06:36
11 processes: 11 sleeping
CPU states:  0.5% user,  0.0% nice,  0.9% system, 98.6% idle,  0.0% iowait
Memory: 2755M used, 13G free, 72M buffers, 2216M cached
DB activity:   8 tps,  0 rollbs/s,   0 buffer r/s, 100 hit%,     40 row r/s,    0 row w/s
DB I/O:     0 reads/s,     0 KB/s,     4 writes/s,    54 KB/s
DB disk: 58.4 GB total, 36.2 GB free (37% used)
Swap: 1024M free

  PID USERNAME PRI NICE  SIZE   RES STATE   TIME   WCPU    CPU COMMAND
 2961 postgres  20    0  272M   19M sleep   0:01  0.58%  0.20% postgres: foo foo 172.17.0.1(37708) idle
 2962 postgres  20    0  272M   19M sleep   0:01  0.52%  0.00% postgres: foo foo 172.17.0.1(37710) idle
 3618 postgres  20    0  269M   14M sleep   0:00  0.00%  0.00% postgres: postgres postgres [local] idle