Get the latest tech news

How often is the query plan optimal?


An evaluation of how often Postgres picks the optimal plan for simple scan queries.

It shows that for selectivities ~1-5% (the x-axis is logarithmic), the planner picks an index scan, but this happens to be a poor choice. The point I tried to make is that the planner picks the plan it believes to be the optimal one, based on the statistics and cost model. I’m sure we can improve the various steps (better stats, better cost model), but there’ll always be some missing details.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of query plan

query plan