pg_stat_monitor
The pg_stat_monitor is a PostgreSQL Query Performance Monitoring tool, based on PostgreSQL contrib module pg_stat_statements. pg_stat_monitor provides aggregated statistics, client information, plan details including plan, and histogram information.
Repository
percona/pg_stat_monitor
https://github.com/percona/pg_stat_monitor
Source
pg_stat_monitor-2.3.2.tar.gz
pg_stat_monitor-2.3.2.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_stat_monitor | 2.3.2 | STAT | BSD-3-Clause | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 6230 | pg_stat_monitor | No | Yes | Yes | Yes | No | Yes | - |
| Related | pg_profile pg_wait_sampling pgsentinel pg_datasentinel powa pg_stat_statements pg_store_plans pg_stat_plans pg_track_settings pg_track_optimizer |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 2.3.2 | 1817161514 | pg_stat_monitor | - |
| RPM | PGDG | 2.3.2 | 1817161514 | pg_stat_monitor_$v | - |
| DEB | PIGSTY | 2.3.2 | 1817161514 | postgresql-$v-pg-stat-monitor | - |
Build
You can build the RPM / DEB packages for pg_stat_monitor using pig build:
Install
You can install pg_stat_monitor directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Install
pig
dnf
apt
Preload:
Create Extension:
Usage
pg_stat_monitor: query performance monitoring tool for PostgreSQL
pg_stat_monitor is an advanced replacement for pg_stat_statements that aggregates statistics into configurable time-based buckets, provides query origin information, actual parameter capture, and query plan details.
Querying Statistics
Key Features
- Time-based buckets: Statistics are grouped into configurable intervals for more accurate analysis
- Client IP tracking: Each query records the originating client IP address
- Actual parameters: Optionally capture real query parameter values instead of placeholders
- Query plans: Each query is accompanied by its actual execution plan
- Top query tracking: Identify the most resource-intensive queries per bucket
- Histogram support: Visual timing distribution via histogram function
Functions
Configuration
Key parameters (set in postgresql.conf):
| Parameter | Description |
|---|---|
pg_stat_monitor.pgsm_max | Maximum number of statements tracked |
pg_stat_monitor.pgsm_query_max_len | Maximum query length |
pg_stat_monitor.pgsm_bucket_time | Bucket duration in seconds |
pg_stat_monitor.pgsm_max_buckets | Maximum number of buckets |
pg_stat_monitor.pgsm_enable_query_plan | Enable query plan capture |
pg_stat_monitor.pgsm_track | Track: top, all, or none |
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)