Stats roll, baby, stats roll.

By Cédric Villemain

Elevator Pitch

PostgreSQL 18’s new cumulative stats system lets extension developers create custom statistics. This talk shows how PACS makes observability seamless, providing counters, gauges, buckets, and histograms integrated, similar to pg_stat_* views.

Description

PostgreSQL 18 offers extension developers support for defining new statistics, using the native PostgreSQL Cumulative Statistics.

We’re talking about stats similar to what’s in pg_stat* views and functions, and how you are able to define your own views and functions.

Using the PACS (PostgreSQL Advanced Cumulative Statistics) extension, we will explore what is offered by PostgreSQL as well as how to define your own new kind of statistics. We will also see how to benefit from the C and SQL API provided by PACS to setup your own gauge, counters, buckets and histogram.

Notes

The opening of the statistics system in PostgreSQL allow us to benefit from an efficient stats engine. I will demonstrate how to use it, how the stats are managed in shared memory, the current API, and so on. Based on previous talk given in Postgres room at FOSDEM 2025, enhanced with updates commited in PostgreSQL in this area meantime.