Skip to content

pg_mon

PostgreSQL extension for query monitoring with execution-time histograms and plan information in a shared view

pg_mon · PostgreSQL extension for query monitoring with execution-time histograms and plan information in a shared view

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100440pg_monpg_mon1.0STATMITC

PostgreSQL · 11, 12, 13, 14, 15, 16, 17

Usage

Sources:

pg_mon records query execution-time and row-count histograms plus scan and join information in shared memory. It must be preloaded:

shared_preload_libraries = 'pg_mon'

Restart PostgreSQL, then create the extension and query its view. Restrict the reset function if ordinary users must not erase monitoring state:

CREATE EXTENSION pg_mon;
REVOKE EXECUTE ON FUNCTION pg_mon_reset() FROM PUBLIC;

SELECT queryid, total_time, actual_rows,
       seq_scans, index_scans, hash_join_count,
       hist_time_ubounds, hist_time_freq
FROM pg_mon
ORDER BY total_time DESC;

Operation

Version 1.0 has an upstream CI matrix for PostgreSQL 11 through 17. pg_mon.plan_info_immediate makes plan information visible after planning but can add locking overhead; pg_mon.plan_info_disable suppresses plan details. Histogram boundaries are fixed, and the collected state is memory-resident rather than a durable history. The install SQL grants SELECT on the view to PUBLIC, so review visibility requirements on shared systems.

Table reader