如何禁用 PostgreSQL 的所有优化 [英] How to disable all optimizations of PostgreSQL

查看:76
本文介绍了如何禁用 PostgreSQL 的所有优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究查询优化,想知道每种优化对查询的帮助有多大.上次,我得到了一个答案,但是在我的实验,禁用链接中的所有优化的时间复杂度为 O(n^1.8) 启用所有优化的时间复杂度为 O(n^0.5).没有太大区别,如果全部禁用,还有其他优化吗?我怎么真的每次只有一个主要优化?

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?

推荐答案

你不能.

PostgreSQL 的查询计划器没有关闭优化"标志.

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.

为了做你想做的事,我认为你需要修改查询规划器代码,重新编译,并为每个测试重新安装 PostgreSQL.或者修改它以添加一堆自定义 GUC(系统变量,例如 enable_seqscan),让您打开和关闭特定优化.

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.

我怀疑任何这样的补丁都会被 PostgreSQL 接受,但作为一次性使用,它值得做.

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

唯一的挑战是 PostgreSQL 并没有在优化"和我们为执行查询所做的事情"之间进行强烈区分.有时,规划器代码的部分期望要求应用了特定的优化才能正常工作.

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.

这篇关于如何禁用 PostgreSQL 的所有优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆