~/talk

A Deep Dive into Postgres Statistics

Talkat PostgreSQL Conference Europe 2024 · 2024-10-22..10-25· [databases]
slides:none on file

Explains exactly how Postgres computes selectivity from pg_stats using most common values, histograms and null fraction, and how equal versus scalar operators are combined into per-clause estimates; shows the default statistics_target=100 and reservoir sampling that builds the sample, and the brute‑force MCV algorithm. Demonstrates concrete mismatches (estimate 297 rows vs actual 5,657 for city+country) and fixes: create statistics multicolumn dependencies and MCVs that cut a GROUP BY from ~800–900ms to ~300ms. Notes histogram bucket math and reservoir sampling limits.

AI-written summary · about

  1. 0:00Introduction and speaker intro
  2. 2:18Viewing Postgres statistics
  3. 5:30Default statistics in Postgres
  4. 14:22Query optimizer and statistics
  5. 16:34Selectivity for equality clauses
  6. 21:52Selectivity for scalar operators
  7. 26:51Combining selectivities in queries
  8. 32:53When statistics fail and solutions
  9. 34:43Extended statistics configuration
  10. 37:12Functional dependency statistics
  11. 38:18NDistinct count statistics
  12. 40:28Multivariate most common values
  13. 43:22Configuring statistics targets
  14. 45:28How Postgres gathers statistics
  15. 50:30Summary and conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.