Repolode
dalibo

dalibo/pg_activity

A top-like command line tool for real-time monitoring of PostgreSQL server activity, sessions and running queries.

Stars
3,051
Forks
196
Open issues
18
Last commit
last month

What is it?

pg_activity shows what a PostgreSQL server is doing right now in a terminal interface similar to top. It lists active backends with their queries, durations, CPU and memory usage, and read/write rates, and it can switch between running, waiting and blocking queries. Users can sort the process table, pause refreshes, copy a focused query to the clipboard, and terminate or cancel backends directly from the interface.

The tool works locally or remotely and accepts standard libpq connection strings and options. It can display instance and system information in the header, and it supports configuration files and built-in profiles such as narrow, wide and minimal to control which columns appear. Filters by database name, CSV export of running queries, and AWS RDS support are also available.

Installation is available through Linux distribution packages, PyPI with psycopg, or from source. Python 3.10 and later are supported.

Key features

  • 01Real-time table of PostgreSQL backends with queries, durations, CPU, memory and I/O rates.
  • 02Switch between running, waiting and blocking query views.
  • 03Terminate or cancel backends directly from the interface.
  • 04Configurable columns and built-in display profiles.
  • 05Filter by database name and export running queries to CSV.

Use cases

  • Diagnosing slow queries or lock contention on a production PostgreSQL server.
  • Watching live connection and I/O activity over SSH on a remote database host.
  • Identifying which sessions are blocking others during an incident.

Quick start

  1. 1

    Install from PyPI with psycopg

    python3 -m pip install "pg_activity[psycopg]"
  2. 2

    Run against a local server as the postgres user

    sudo -u postgres pg_activity -U postgres

Things to know

  • Requires a PostgreSQL user with superuser rights for full data; otherwise it runs in a degraded mode.

In collections

Topics

FAQ

What is pg_activity?
A top-like command line tool for real-time monitoring of PostgreSQL server activity, sessions and running queries. pg_activity shows what a PostgreSQL server is doing right now in a terminal interface similar to top. It lists active backends with their queries, durations, CPU and memory usage, and read/write rates, and it can switch between running, waiting and blocking queries. Users can sort the process table, pause refreshes, copy a focused query to the clipboard, and terminate or cancel backends directly from the interface.
Is pg_activity free to use? What license does it have?
pg_activity is open source under the PostgreSQL license. Check the license terms before using it in commercial products.
Is pg_activity still maintained?
Updated within 6 months. The last commit to pg_activity was on Sep 21, 2026.
What can I use pg_activity for?
Diagnosing slow queries or lock contention on a production PostgreSQL server. Watching live connection and I/O activity over SSH on a remote database host. Identifying which sessions are blocking others during an incident.
How do I install pg_activity?
Install from PyPI with psycopg: python3 -m pip install "pg_activity[psycopg]" Run against a local server as the postgres user: sudo -u postgres pg_activity -U postgres
Where can I get pg_activity?
The source code and installation instructions are on GitHub: https://github.com/dalibo/pg_activity

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects