CustomCumulativeStats

From PostgreSQL wiki
Jump to navigationJump to search

Custom Cumulative Statistics (pgstats)

Extensions can register their own custom cumulative statistics to the gathering of any statistical data using the same APIs as PostgreSQL's backend pgstats.

Each custom cumulative statistics needs to register using a unique ID (across all extensions) to prevent problems with conflicts when handling the stats data (hash key in dshash table, read and write of pgstats file). The IDs are limited at compile-time, however, and only IDs between 128 and 255 (inclusive) are available natively for custom cumulative statistics as of PostgreSQL 18. It is possible to change this limit.

This page lists the current extensions that require custom cumulative stats, and the IDs which are reserved for them. If your extension requires a new type of custom cumulative statistics, start out by using PGSTAT_KIND_EXPERIMENTAL (128). When the project is close to release or being used in production, choose an unused stats kind ID and add to this list to reserve it.

End-users must ensure that the extensions they deploy do not conflict, while it's not expected with open source extensions for which authors must take care of the current list, close source extensions could easily overlap.

List of Custom Stats

KindId Extension Description License
128 N/A Used for extensions still in development N/A
129 N/A In-core test module injection_points, variable-numbered case N/A
130 N/A In-core test module injection_points, fixed-numbered case N/A