pg_stats: How Postgres Internal Stats Work | POSETTE: An Event for Postgres 2026

Estimated read time 2 min read

Post Content

​ Learn how Postgres internal statistics influence query planning. Richard Yen (Microsoft) explains in his talk “pg_stats: How Postgres Internal Stats Work” at POSETTE: An Event for Postgres 2026. Abstract: Why does Postgres sometimes choose a Sequential Scan over an Index Scan, even when it seems slower? The answer almost always lies in the statistics. The query planner relies on a mathematical model of your data distribution to make decisions, and when that model is wrong, performance suffers.

In this session, we will crack open the pg_stats view to understand exactly how Postgres “sees” your data. We will cover histograms, most common values (MCV), and correlation. We will also explore Extended Statistics, a powerful feature for fixing bad query plans on correlated columns (like City and State), ensuring your planner stops guessing and starts knowing.

Richard Yen is a Senior Software Engineer at Microsoft with over 20 years of hands‑on experience operating PostgreSQL in production environments. He has worked across support, SRE, and engineering roles, helping organizations design, run, and recover large‑scale PostgreSQL systems. Richard’s work focuses on reliability, observability, and disaster recovery—bridging the gap between PostgreSQL internals and real‑world operational practices. He is a frequent contributor to the PostgreSQL community through talks and writing, sharing lessons learned from incidents, outages, and long‑running production systems.

► Video chapters:
⏩ 00:00 – Music & introduction
⏩ 00:30 – Why Postgres ignores your index
⏩ 02:00 – How the query planner thinks
⏩ 04:34 – Exploring pg_statistic and pg_stats
⏩ 06:10 – Understanding null fractions and cardinality
⏩ 08:15 – Most common values
⏩ 09:20 – Cost estimation for sequential and index scans
⏩ 12:25 – Why the planner chooses different plans
⏩ 16:30 – Understanding range selectivity with histograms
⏩ 18:35 – Improving planner accuracy with statistics
⏩ 19:55 – Improving planner accuracy with CREATE STATISTICS
⏩ 22:55 – Query planning checklist & final performance tuning tips

📕 Everything you need to know about POSETTE: An Event for Postgres can be found at: https://posetteconf.com
✅ Learn more: watch more POSETTE talks: https://aka.ms/posette-playlist

📌 Let’s connect:
LinkedIn: https://www.linkedin.com/company/posetteconf/
X – @PosetteConf, https://x.com/PosetteConf
Mastodon – @posetteconf, https://mastodon.social/@posetteconf
Bluesky – @posetteconf.com, https://aka.ms/posette-on-bluesky

#PosetteConf #PostgreSQL #database   Read More Microsoft Developer 

You May Also Like

More From Author