Alena Rybakina has submitted a new session!

PostgreSQL Optimizer Flaws: Real Stories and How We Fix Them

The PostgreSQL optimizer usually does a solid job producing efficient query plans. But sometimes, it underestimates cardinality or misjudges query structure, leading to seriously inefficient plans and blown-out execution times.

In this talk, we'll dive into some of the most unusual and surprising real-world cases where the optimizer got it wrong. We'll analyze the root causes behind these failures and walk you through how we tackled them — from the initial idea to real feature implementations like "OR-to-ANY Transformation" [0], "VALUES-to-ANY Transformation"[1], Replanning [2], and smart extensions like AQO [3], Switch Join [4], and more.

You'll leave with a better understanding of how the optimizer works and where its weak spots are - plus fresh ideas on how to outsmart it.

[0] https://github.com/postgres/postgres/commit/d4378c0005e61b1bb78e88097ea6efcdddbe2d6e
[1] https://github.com/postgres/postgres/commit/c0962a113d1f2f94cb7222a7ca025a67e9ce3860
[2] https://habr.com/ru/companies/postgrespro/articles/819911/
[3] https://www.pgevents.ca/events/pgconfdev2024/schedule/session/147-adaptive-query-optimization-in-postgresql/
[4] https://www.pgevents.ca/events/pgconfdev2025/callforpapers/346/

Open session

These notifications can be turned off on Edit event page.