pg_stat_monitor
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.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 6240 | pg_stat_monitor | pg_stat_monitor | 2.4.1 |
STAT | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-r | No | Yes | Yes | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | pg_profile pg_wait_sampling pgsentinel pg_datasentinel powa pg_stat_statements pg_store_plans pg_stat_plans pg_track_settings pg_track_optimizer |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 |
| el8.aarch64 | N/A | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 |
| el9.x86_64 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 |
| el9.aarch64 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 |
| el10.x86_64 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 |
| el10.aarch64 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 | PGDG 2.4.1 |
| d12.x86_64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
| d12.aarch64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
| d13.x86_64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
| d13.aarch64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
| u22.x86_64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
| u22.aarch64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
| u24.x86_64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
| u24.aarch64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
| u26.x86_64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
| u26.aarch64 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 | PIGSTY 2.4.1 |
Source
github.com/percona/pg_stat_monitor
pg_stat_monitor-2.4.1.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
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 |