Skip to content
Rate this page
Thanks for your feedback
Thank you! The feedback has been submitted.

Get free database assistance or contact our experts for personalized support.

Version 2.4.0 (2026-09-08)

Install pg_stat_monitor

Release highlights

This release is focused on the stability and reliability of pg_stat_monitor. Large parts of the internals were reworked to remove long-standing sources of crashes, memory leaks and incorrect statistics, and the test suite was extended with test cases backported from pg_stat_statements so that the behavior of both extensions can be compared directly.

The release also adds support for PostgreSQL 19 beta 3, drops PostgreSQL 13 support, removes the deprecated pg_stat_monitor.pgsm_overflow_target parameter and deprecates pg_stat_monitor.pgsm_track_application_names.

Important

This release changes the values reported in several columns of the pg_stat_monitor view and removes a configuration parameter. Read the Breaking changes and deprecations section before you upgrade.

Breaking changes and deprecations

PostgreSQL 13 support is removed

PG-2187 - pg_stat_monitor 2.4.0 requires PostgreSQL 14 or later. If you run PostgreSQL 13, stay on pg_stat_monitor 2.3.2 or upgrade PostgreSQL first.

The pgsm_overflow_target parameter is removed

PG-2279 - The pg_stat_monitor.pgsm_overflow_target parameter was deprecated in version 2.0.0 and had no effect since then. It is now removed. Use pg_stat_monitor.pgsm_enable_overflow instead.

The pgsm_track_application_names parameter is deprecated

PG-2602 - The application name is now always tracked. The pg_stat_monitor.pgsm_track_application_names parameter has no effect. The performance overhead that this parameter existed to avoid has been fixed, so tracking application names no longer costs you anything. Remove the parameter from your configuration.

Unprivileged users see fewer columns of other users’ queries

PG-2624 - Previously only query, query_plan and client_ip were restricted, which meant that an unprivileged user could still read queryid, pgsm_query_id, planid, top_queryid, top_query, message and comments for statements executed by other users. Because queryid is a hash of the normalized query text, publishing it defeated the restriction on the query text itself.

All identifying and text columns are now restricted to the row owner and to roles with the privileges of pg_read_all_stats. See Views for the full list.

Changed column values

  • PG-1459 - username and datname are now empty when the real name cannot be resolved, for example after the role or the database was dropped. Previously they contained the <user name not available> and <database name not available> placeholder strings.
  • application_name is now NULL when the client did not set an application name. Previously it was the literal string unknown.
  • The plans counter now reflects only actual planner invocations. Utility statements and executions that reuse a cached plan no longer increase it, and the associated total_plan_time, min_plan_time, max_plan_time, mean_plan_time and stddev_plan_time values are corrected accordingly.

Non-PGXS builds are removed

All support for building pg_stat_monitor from within the PostgreSQL source tree under contrib/ is removed, so there is now a single way to build the extension. Specifying USE_PGXS=1 is no longer necessary — run make and make install. See Install pg_stat_monitor.

Improvements

PostgreSQL 19 beta 3 support

PG-2424 - pg_stat_monitor builds and runs against PostgreSQL 19 beta 3, including the following:

  • Two new counters backported from pg_stat_statements: generic_plan_calls and custom_plan_calls, which track how many times a prepared statement was executed with a generic or a custom plan
  • Support for property graphs, which are listed in the relations column with a trailing *, the same way as views, together with their underlying element tables
  • Use of the ComputeConstantLengths API for squashing lists of constants in the query text

Note

PostgreSQL 19 has not been released yet. Support for PostgreSQL 19 beta 3 is provided so that you can test pg_stat_monitor against it, and the version is not covered by the same level of testing as PostgreSQL 14 to 18.

Other improvements

  • PG-2547 - Added support for EXEC_BACKEND builds, which removes shortcuts in our shared memory handling and is a prerequisite for Windows support
  • PG-2623 - The query text of utility statements is now normalized when pg_stat_monitor.pgsm_normalized_query is enabled, so statements such as EXPLAIN SELECT 1 and DECLARE c CURSOR FOR SELECT 1 are stored with placeholders instead of literals. This also makes pgsm_query_id stable for utility statements
  • PG-2281, PG-2557 - The user name and the application name are now saved before the statement runs, so a SET ROLE or a SET application_name statement is recorded with the values that were in effect when it was issued, not with the values it set
  • PG-2182 - Backported test cases from the pg_stat_statements regression suited
  • The name and version of pg_stat_monitor are now reported by pg_get_loaded_modules() on PostgreSQL 18 and later
  • The unit of pg_stat_monitor.pgsm_query_max_len is now reported as bytes in pg_settings
  • The decode_error_level(), get_cmd_type(), pg_stat_monitor_version(), range() and histogram() functions are now marked STABLE, LEAKPROOF and PARALLEL SAFE where applicable, so they can be used in parallel plans
  • The pgsm_create_view() internal function is dropped after CREATE EXTENSION finishes instead of being left in the database

Bug fixes

  • PG-2229 - Fixed a memory leak that occurred when MessageContext was not valid, by scoping the local memory context to the current transaction
  • PG-2511 - Fixed a potential buffer overflow with deeply nested queries, which a superuser could trigger by raising max_stack_depth
  • PG-2735 - Fixed a buffer overflow in query normalization
  • PG-2540 - Fixed a buffer overread when a query ends with a comment, whether closed or unclosed
  • PG-2485 - Fixed an off-by-one bug in comment extraction
  • PG-2486 - pg_stat_monitor no longer accesses the PlannedStmt structure after standard_ProcessUtility() was called, where it may already have been freed
  • PG-1724 - Fixed a possible array bounds overflow in the histogram code
  • PG-1723 - Replaced unsafe string handling throughout the code
  • PG-2212 - Fixed the client address lookup, which used the wrong key and therefore reported client_ip as 127.0.0.1 for almost every connection
  • Fixed the confusion of local_blk_read_time and local_blk_write_time, where write times were recorded in both fields
  • Fixed a performance issue when saving the application name, which degraded proportionally to the number of connections
  • Fixed a race condition that could leak memory for the parent query
  • Fixed the statistics of queries executed through prepared statements, where a statement that changes the user or the application name could produce an entry with incorrect metadata
  • pg_stat_monitor no longer acquires an LWLock while holding a spinlock