6 ms·
In Postgres until 9.2, the query plan for prepared statements is fixed at prepare time rather than time of execution, so you might end up with worse query plans
by greenleafjacob 10y ago
In Postgres until 9.2, the query plan for prepared statements is fixed at prepare time rather than time of execution, so you might end up with worse query plans. It's worth noting that 9.1 is still the version in Ubuntu 12.04, it's only 14.04 that has 9.3.
- raverbashing 10y agoIn which case different values would end up have a different query plan? NULL values?
- ComodoHacker 10y agoSkewed distribution.
- sixbrx 10y agoThat's one of the main points of gathering statistics, so the query plan can depend on the values being queried. At least in Oracle, not sure about Postgres. For long running queries it can be a big win.
- greenleafjacob 10y agoHere is an example [1] that just is a simple equality comparison on an indexed column falling back to a sequential table scan. [1] http://blog.endpoint.com/2014/04/custom-plans-prepared-statements-in.html http://blog.endpoint.com/2014/04/custom-plans-prepared-state...
- icebraining 10y agoIt should be noted that Postgres offers a repository with the latests versions even for Ubuntu 12.04, so you don't need to upgrade the distro or compile PG yourself to use them.
- hultner 10y agoThis have been an annoyance in many DBMS-engines, I have previously solved it with recompiles, either triggered or nightly/hourly.
- jldugger 10y ago> It's worth noting that 9.1 is still the version in Ubuntu 12.04, it's only 14.04 that has 9.3. And the most recent LTS, 16.04, has 9.5.