Server dashboard

A periodic sample of pg_stat_database, pg_stat_activity, lock waits, the pg_stat_progress_* views, pg_locks, pg_prepared_xacts and pg_settings, with pg_cancel_backend() / pg_terminate_backend() on a key.

The server dashboard
Graphs, summary, the Sessions list.

Opening the dashboard

Alt+D (also Ctrl+D) on a row of a connected server; Tools → Server dashboard; the context menu (F2).

Tree cursor onScopeSession on
the server row, Databases, a role, a tablespaceThe cluster: all databases summed.the maintenance database
a database or anything inside itThat database: every query is filtered by datname.that database

Refreshing

Key
F5Refresh now; reconnect after a lost session.
Ctrl+PPause / resume.
Ctrl+TInterval: 0.5 → 1 → 2 (default) → 5 → 10 → 30 s.

The next refresh is timed from the answer of the previous one, so requests do not pile up. The list cursor stays on its PID.

The graphs

BoxSource
Sessions: total · active · idlepg_stat_activity, backend_type = 'client backend', by state.
Transactions per secondxact_commit, xact_rollback.
Tuples intup_inserted, tup_updated, tup_deleted.
Tuples outtup_fetched, tup_returned.
Block I/Oblks_read, blks_hit.

Rates are the difference of two samples of pg_stat_database (summed on a cluster dashboard) divided by the difference of the server's clock_timestamp(). On a low window the graphs are dropped first. If the statistics query fails, its error is shown where the graphs are; the list below goes on.

The summary

LineValueSource
Globalprimary / standby, uppg_is_in_recovery(), pg_postmaster_start_time().
size (+ bytes/s)Sum of pg_database_size(), read at most every 30 s and on F5. Databases without CONNECT for your role are skipped.
cache hitblks_hit / (blks_hit + blks_read) between the last two samples, not since stats_reset.
rollbackxact_rollback as a share of all transactions.
temporary filesCount and size from pg_ls_tmpdir() over all tablespaces, right now. PostgreSQL 12+; needs EXECUTE on the function (superuser, pg_monitor).
Sessions41 / 200, by stateClient backends out of max_connections, by state.
waitingClient backends with wait_event_type = 'Lock'.
oldest transaction, longest querySmallest xact_start; smallest query_start of an active backend. WAL senders are left out.
oldest xmin and its PIDLargest age(backend_xmin).
Workersautovacuum, parallel, logical replicationBackends by backend_type out of autovacuum_max_workers, max_parallel_workers, max_logical_replication_workers.
deadlocks, conflicts, checksum failuresIncrease of deadlocks, conflicts, checksum_failures (12+) since the previous refresh; above 0 in the warning colour.
ReplicationWAL senders, receivers, slotspg_stat_replication out of max_wal_senders, pg_stat_wal_receiver, pg_replication_slots out of max_replication_slots.
lagLargest pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn). Primary only; needs monitoring privileges.
slot WALLargest distance from a slot's restart_lsn to the current WAL position (replay position on a standby).

On a database dashboard the Sessions line and the pg_stat_database values are that database's; workers, replication and temporary files are always cluster-wide.

The lists

Sessions · Blocking · Progress · Locks · Prepared transactions · Configuration. They are the grid of query results: see The grid.

Key
Alt+Right / Alt+LeftNext / previous list (also Ctrl+PgDn / Ctrl+PgUp, Alt+PgDn / Alt+PgUp).
EnterThe whole row in a window.
Ctrl+CCopy the cell; after Ctrl+A, the list.
F2Context menu.

Sessions

The rows of pg_stat_activity, auxiliary processes included, under the view's column names. What is not a plain column:

Column
Wait eventwait_event_type: wait_event.
Blocked bypg_blocking_pids(pid), computed only for wait_event_type = 'Lock'.
DurationSee below.
Xmin ageage(backend_xmin).
Leader PIDleader_pid (13+); workers are listed after their leader.
Query IDquery_id (14+).

Row colours

Theme roleThe session
dashboard.idle_in_transactionis idle in transaction.
dashboard.blocking / dashboard.blockedholds a lock others wait for / waits for a lock.
dashboard.slow / dashboard.very_slow (Duration cell)≥ 1 s / ≥ 10 s.
dashboard.taggedis tagged.

Duration and order

The statement pane

The dashboard with its statement pane
The statement of the row under the cursor.

Under Sessions, Blocking and Progress; a read-only SQL view.

Key
Ctrl+RHide / show the pane.
Alt+Down / Alt+UpInto the pane / back.
Alt+Shift+Up / Alt+Shift+DownSmaller / larger (or drag its upper line).
Ctrl+EThe statement in a new query tab on the backend's database.

The whole row

Blocking

The Blocking list
PID 41377 blocks PID 41502; the pane shows the blocker's last statement.

One row per pair: every backend with wait_event_type = 'Lock', joined to each PID in its pg_blocking_pids().

Progress

The Progress list

The union of the pg_stat_progress_* views the server has (vacuum 11; cluster, create_index 12; analyze, basebackup 13 — cluster dashboard only; copy 14), joined to pg_stat_activity.

Locks

pg_locks without the dashboard's own rows. Granted is yes / no.

Prepared transactions

pg_prepared_xacts.

Configuration

pg_settings: name, category, setting (in the base unit), unit, short_desc. Source and file of each setting: the server row in the tree.

Cancelling a query, terminating a session

In Sessions, Blocking and Progress, on the row under the cursor:

Key
Alt+Shift+Cpg_cancel_backend(pid)
F8pg_terminate_backend(pid)

Several sessions at once: tagging

Tagged sessions
Two tagged sessions.

In Sessions, Insert tags / untags the row and moves down; Esc removes all tags. With tags set, Alt+Shift+C and F8 act on all tagged sessions, after one question. The tag of an exited backend goes with it.

All dashboard keys

Key
F5Refresh now; reconnect.
Ctrl+PPause / resume.
Ctrl+TRefresh interval.
Alt+Right / Alt+LeftNext / previous list.
Alt+IHide / show idle sessions.
Alt+TDuration mode.
Insert / EscTag / remove all tags.
EnterThe whole row.
Alt+Shift+CCancel query.
F8Terminate session.
Ctrl+RStatement pane.
Ctrl+EThe statement in a new query tab.
Ctrl+CCopy.