I'm investigating an issue with DB connections being left open indefinitely, causing problems on the DB server. How do I see currently open connections to a PostgreSQL server, particularly those using a specific database? Ideally I'd like to see what command is executing there as well. Basically, I'm looking for something equivalent to the "Current Activity" view in MSSQL.
OK, got it from someone else. This query should do the trick:
See also pg-top, which acts like top except it shows postgres activity.
sudo su postgres
)pg_top
Reference taken from this article.
Two ways to monitor in Ubuntu 18.04, just for reference
One using
pg_top
:Two using
pgAdmin4
:In the dashboard, check the total/active as
PostgreSQL ASH Viewer (PASH Viewer) provides graphical view of active session history data. https://github.com/dbacvetkov/PASH-Viewer It's free and open source.
ScreenShot
DBeaver is also showing the active/idle/total server sessions very nicely.