Statistics for the Planner: PostgreSQL Row Estimates
Learn where the PostgreSQL planner's row estimates come from and why a wrong estimate produces a slow plan. Find inaccurate statistics and correct them.
- €200per person, before VAT
- 1 live session2 hours 30 minutes
- Theory and live demoswith Q&A
- Live online via Zoomin English
- Certificate of Attendance
Upcoming dates
Booking for a company or public body? Need a quote, purchase order or invoice? Email contact@dataegret.com and we'll arrange it.
What you'll learn
PostgreSQL chooses a plan by estimated cost, and the estimates come from statistics. This session shows how those statistics are collected, how to read them, and what to do when they mislead the planner.
The course covers
- Cost-based optimisation: why the plan with the lowest estimated cost is not always the fastest
- How ANALYZE and autoanalyze sample a table and store the results
- Reading pg_stats: most common values, histograms, n_distinct and correlation
- How row counts are estimated for equality, ranges and combined predicates
- Extended statistics with CREATE STATISTICS for correlated columns
- Common causes of bad estimates: stale statistics, skew, expressions, very large tables and joins
- Statistics settings such as default_statistics_target, and what changes when you upgrade to PostgreSQL 18
Prerequisites
For developers who have seen PostgreSQL choose a slow plan for no visible reason and want to know where the estimate went wrong.
You should be comfortable writing SQL. The session is self-contained: no other session of the track is required.
For details see the course terms & conditions.
Syllabus
1Cost-based optimisation
- Rule-based against cost-based planning.
- The parse, plan and execute stages; reading EXPLAIN.
- What "cost" means, and the five cost constants.
2Statistics and where they live
- pg_statistic and pg_stats.
- Sampling, manual ANALYZE and autoanalyze.
- default_statistics_target and per-column targets.
3Planning challenges
- Row counts for equality and ranges.
- The multiplication rule and correlated columns; CREATE STATISTICS and pg_stats_ext.
- Join cardinality, collapse limits and GEQO.
4Where the planner struggles
- Stale statistics, skew, expressions and functions.
- Rapidly changing data, and insufficient sampling on very large tables.
5Statistics after an upgrade
- What pg_upgrade preserves in PostgreSQL 18.
- The post-upgrade ANALYZE workflow.
Frequently asked questions
Who is this session for?
Developers who want to understand why PostgreSQL picks the plan it does. It assumes working SQL, not knowledge of PostgreSQL internals.
Can I book this session on its own?
Yes. Every session of the developer track is self-contained. It is also one of the seven sessions of High Performance SQL with Postgres, which you can book in full at a package price.
Is the session recorded?
No. The session is live, with time for questions, and is not recorded. You receive the handouts: the slides with the trainer's commentary and the full demo transcripts.
Can my company pay by invoice?
Yes — write to contact@dataegret.com and we invoice your company; card booking is also available online.
Instructors

Over 15 years of experience across Oracle, DB2, MySQL, SQL Server and PostgreSQL. A recognised PostgreSQL contributor, active in the community through committees, user groups and international conferences.

Over 20 years of industry experience, with extensive expertise in supporting clients on their PostgreSQL journey and achieving high availability for business-critical projects.
Ready to book, or still deciding?
Live, small-group, taught by the people who run PostgreSQL in production. Questions first? Write to us — no sales pitch.
