3 ms·
Related discussion Why PostgreSQL doesn't have query hints https://news.ycombinator.com/item?id=2179433 https://news.ycombinator.com/item?id=2179433 (60 comme
by sa46 3y ago
Related discussion
Why PostgreSQL doesn't have query hints
https://news.ycombinator.com/item?id=2179433 https://news.ycombinator.com/item?id=2179433 (60 comments, 2011)
The official stance from the Postgres wiki https://wiki.postgresql.org/wiki/OptimizerHintsDiscussion https://wiki.postgresql.org/wiki/OptimizerHintsDiscussion:
> We are not interested in implementing hints in the exact ways they are commonly implemented on other databases.
> Problems with existing Hint systems: Poor application code maintainability, Interference with upgrades, Encouraging bad DBA habits, Does not scale with data size
I don't fault their stance, but it's frustrating when Postgres picks a stupid plan and can't be convinced to do something reasonable.
- s08148692 3y ago> when Postgres picks a stupid plan and can't be convinced to do something reasonable. In my experience it can always be convinced to make a reasonable plan, but it's not always trivial. Sometimes it's just adding an index, sometimes it's entirely rewriting a query
- CubsFan1060 3y agoAgreed. I've found this setting to be difficult: https://postgresqlco.nf/doc/en/param/default_statistics_target/ https://postgresqlco.nf/doc/en/param/default_statistics_targ... Too low == bad query plan. Oddly, too high == bad query plan.
- Izkata 3y agoThere's also "the query plan you want won't do what you expect, so I'm giving you the next best thing until you tell me the right way to store the data": https://news.ycombinator.com/item?id=39311536 https://news.ycombinator.com/item?id=39311536