4 ms·
It's not really true. There are many session-scoped flags you can set which influence planner behavior, and sometimes toggling them for a specific query is what
by barrkel 1y ago
It's not really true. There are many session-scoped flags you can set which influence planner behavior, and sometimes toggling them for a specific query is what gets you through. More often, judicious use of CTEs as an optimization barrier (materialized CTE in moderrn versions) is useful to force execution order.
I like that Postgres has a lot of tools at its disposal for executing queries. But you can't rely on it for data even with modest scale. It's rare that it does a good job with interesting queries.
- williamdclt 1y agoI think we’re saying the same thing: you can’t force PG to a plan or an index, you can only change your query in hope it gets the hint. Even session scoped flags are a really coarse tool, don’t guarantee you’ll get the plan you want and it might unexpectedly impact other queries in the session. Materialised CTE are one of the only tools that give real control, but an optimisation barrier is often the opposite of what you want