How to disable all optimizations of PostgreSQL

白昼怎懂夜的黑 提交于 2021-01-28 03:00:40

问题


I'm studying query optimization and want to know how much each kind of optimizations help the query. Last time, I got an answer but when in my experiments, disable all optimization in the link has time complicity of O(n^1.8) enable all of them has O(n^0.5). there is not so much difference, if disable all of them, is there still other optimizations? how can I really have only one main optimizations each time?


回答1:


You can't.

PostgreSQL's query planner has no "turn off optimisation" flag.

It'd be interesting to add, but would make the regression tests a lot more complex, and be of very limited utility.

To do what you want, I think you'd want to modify the query planner code, recompile, and reinstall PostgreSQL for each test. Or hack it to add a bunch of custom GUCs (system variables, like enable_seqscan) to let you turn particular optimisations on and off.

I doubt any such patch would be accepted into PostgreSQL, but it'd be worth doing as a throwaway.

The only challenge is that PostgreSQL doesn't differentiate strongly between "optimisation" and "thing we do to execute the query". Sometimes parts of the planner code expect and require that a particular optimisation has been applied in order to work correctly.



来源:https://stackoverflow.com/questions/22857855/how-to-disable-all-optimizations-of-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!