pg_stat_monitor is a statistics collection tool authored by Percona and contributed to the community. It is based on pg_stat_statements, an existing PostgreSQL contrib module. The major shortcoming in pg_stat_statements is that it accumulates all the queries and their statistics but does not provide aggregated statistics nor histogram information. In this case, a user needs to calculate the aggregate, which is quite expensive. pg_stat_monitor provides the pre-calculated aggregates.

pg_stat_monitor collects and aggregates data on a bucket basis. The size and number of buckets is configured using GUC (Grand Unified Configuration). The buckets are used to collect the statistics and aggregate them into a bucket. This talk covers the usage of pg_stat_monitor and how it is an improvement on pg_stat_statements. pg_stat_monitor is added to Percona Monitoring and Management to collect query metrics. This provides users the ability to see examples instead of fingerprints. pg_stat_monitor provides more accurate data because of bucket based logic. Also, collecting data from pg_stat_monitor provides better performance than pg_stat_statements.

Related Videos: PostgreSQL, Percona Monitoring and Management

Introduction to pg_stat_monitor
PostgreSQL High-Performance Tuning and Optimization
Using PMM to Identify and Troubleshoot Problematic MySQL Queries
Why PostgreSQL Is Becoming A Migration Target For Enterprise
The "411" on PMM - Brandon Fleisher and Steve Hoffman - Percona Live ONLINE 2020
SQL Row Store vs Data Warehouse: Which Is Right for Your Application? - Robert Hodges - PLO October 2020
Introducing Kunlun Distributed Database Cluster - David Zhao Wei - Percona Live ONLINE 2020