PostgreSQL 18 introduced two new functions, pgrestorerelationstats and pgrestoreattributestats, that allow database administrators to write optimizer statistics directly into catalog tables without requiring actual data, enabling production-scale statistics to be exported and used in testing environments or CI pipelines. The feature addresses the problem where query planners make different decisions based on vastly different data volumes—such as 1,000 rows in CI versus 50 million in production—allowing developers to reproduce production query plans locally for debugging and regression testing.
1 comment
PostgreSQL 18 introduced two new functions, pgrestorerelationstats and pgrestoreattributestats, that allow database administrators to write optimizer statistics directly into catalog tables without requiring actual data, enabling production-scale statistics to be exported and used in testing environments or CI pipelines. The feature addresses the problem where query planners make different decisions based on vastly different data volumes—such as 1,000 rows in CI versus 50 million in production—allowing developers to reproduce production query plans locally for debugging and regression testing.