当前位置:网站首页>修改隐含参数造成SQL性能下降案例之一
修改隐含参数造成SQL性能下降案例之一
2022-06-22 18:23:00 【老虎刘】
在某客户现场发现了一个执行了很长时间(15.8小时)仍未执行完的SQL,而且SQL使用了8个并行进程:
SQL代码如下:
SELECT /*+ PARALLEL(a,8)*/ count(: "SYS_B_0")
FROM so1.ins_srv_attr_780 a
WHERE a.offer_inst_id IN
(
SELECT /*+parallel(b,8)*/ b.offer_inst_id
FROM so1.ins_offer_780 b
WHERE b.offer_type = : "SYS_B_1"
) AND
a.prod_srv_relat_id NOT IN
(
SELECT c.prod_srv_relat_id
FROM so1.ins_prod_ins_srv_780 c
);
SQL包含一个IN和一个NOT IN,执行计划中not in的filter步骤效率低,而且这一步还漏写了并行hint(不是主要问题)。为什么优化器会选择这样低效的执行计划?
客户修改了多个隐含参数:
OPT_PARAM('_optimizer_use_feedback' 'false')
OPT_PARAM('_optimizer_join_factorization' 'false')
OPT_PARAM('_optimizer_enable_density_improvements' 'false')
OPT_PARAM('_optimizer_adaptive_cursor_sharing' 'false')
OPT_PARAM('_optimizer_extended_cursor_sharing_rel' 'none')
OPT_PARAM('_bloom_pruning_enabled' 'false')
OPT_PARAM('_gby_hash_aggregation_enabled' 'false')
OPT_PARAM('_optimizer_join_elimination_enabled' 'false')
OPT_PARAM('_optimizer_extended_cursor_sharing' 'none')
OPT_PARAM('_bloom_filter_enabled' 'false')
OPT_PARAM('_optimizer_squ_bottomup' 'false')
经过执行排查,发现其中的罪魁祸首就_optimizer_squ_bottomup:
我们来看看这个参数为默认TRUE的时候SQL的执行情况(顺便修正了并行写法问题):
SELECT /*+ PARALLEL(8) OPT_PARAM('_optimizer_squ_bottomup' 'true') */ count(1)
FROM so1.ins_srv_attr_780 a
WHERE a.offer_inst_id IN
(
SELECT b.offer_inst_id
FROM so1.ins_offer_780 b
WHERE b.offer_type = 'OFFER_PLAN_BBOSS'
) AND a.prod_srv_relat_id NOT IN
(
SELECT c.prod_srv_relat_id
FROM so1.ins_prod_ins_srv_780 c
);
效果直接看下图:
系统参数,尤其是隐含参数,在没有遇到bug的情况下,一般不建议修改,这个案例就是非常明显的一个教训。
边栏推荐
猜你喜欢
![[suggestions collection] common usage scenarios of message queue](/img/58/87dae469e5142507f2a5d100975b8e.png)
[suggestions collection] common usage scenarios of message queue

推荐一个解剖学网站

0.1-----用AD画PCB的流程

1.2-----机械设计工具(CAD软件)和硬件设计工具(EDA软件)及对比

Interface development component devaxpress asp Net core v21.2 - UI component enhancements

what? Homekit, Micah, aqara and other ecosystems can also be linked with tmall elf ecology through zhiting?
组合学笔记(五)分配格中的链

集群、分布式、微服务概念和区别

Flutter系列-flutter路由管理

Digital supply chain centralized purchase platform solution for mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase
随机推荐
what? Homekit, Micah, aqara and other ecosystems can also be linked with tmall elf ecology through zhiting?
Shell编程规范与变量
Altium Designer中off grid pin解决方法
Online generation of placeholder pictures
Aiops intelligent operation and maintenance experience sharing
Ts as const
Message Oriented Middleware (I) MQ explanation and comparison of four MQS
结构型模式之适配器模式
技术管理进阶——你了解成长的全貌吗?
1.4----- PCB design? (circuit design) determination scheme
Velocity 语法
1.2-----机械设计工具(CAD软件)和硬件设计工具(EDA软件)及对比
Experiment 7 trigger
k8s部署mysql
知识蒸馏之Focal and Global Knowledge Distillation for Detectors
Quick indent usage in VIM
Flutter series -dart basic grammar learning
Initial experience of ABAQUS using RSG drawing plug-in
[nfs无法挂载问题] mount.nfs: access denied by server while mounting localhost:/data/dev/mysql
Shell script explanation (II) -- conditional test, if statement and case branch statement