Keep PostgreSQL from sometimes choosing a bad query plan

后端 未结 5 1747
梦毁少年i
梦毁少年i 2020-11-22 11:51

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 OUT

5条回答
  •  独厮守ぢ
    2020-11-22 12:19

    What Erwin said about the statistics. Also:

    ORDER BY parentid DESC, id, z_diff
    

    Sorting on

    parentid DESC, id, z
    

    might give the optimiser a bit more room to shuffle. (I don't think it will matter much since it is the last term, and the sort is not that expensive, but you could give it a try)

提交回复
热议问题