sql-execution-plan

Keep PostgreSQL from sometimes choosing a bad query plan

随声附和 提交于 2019-11-26 00:18:29
问题 I have a strange problem with PostgreSQL performance for a query, using PostgreSQL 8.4.9. This query is selecting a set of points within a 3D volume, using a LEFT OUTER JOIN to add a related ID column where that related ID exists. Small changes in the x range can cause PostgreSQL to choose a different query plan, which takes the execution time from 0.01 seconds to 50 seconds. This is the query in question: SELECT treenode.id AS id, treenode.parent_id AS parentid, (treenode.location).x AS x,