当前位置:网站首页>再谈SQL profile : 到底能不能固定执行计划?
再谈SQL profile : 到底能不能固定执行计划?
2022-06-22 18:23:00 【老虎刘】
在我发布了使用coe_load_sql_profile.sql脚本可以解决生产系统执行计划突然变差的文章后,第二天刚好又看到一篇文章:《执行计划:Oracle的Profile特性与SQL执行计划的稳定性》,文章专门对sql profile做了深入的介绍,对了解SQL profile的原理很有帮助。因为撰写人和转发者都是业内大拿,粉丝众多,看了那篇文章的人应该非常多,因此有必要对那篇文章的一个小瑕疵加以纠正,即“SQL profile不能固定执行计划”这个结论是不准确的,只是在某种测试条件下的一种结果。
下图是截取文章的结论部分:
在文章作者使用的Test case中,应该确实能得到这样的结果,但是结论却不够完整,会给读者一个误导:SQL prfofile不能固定执行计划。
上述结论是使用oracle的sql tuning advisor工具生成的sql profile(只写入一个opt_estimate的有一个hint),作为一个优化工具,对这样一个SQL不做完全固定也是可以理解的。这个也提醒了我们的DBA,用sql tuning advisor做的sql profile不一定能固定执行计划。
我想补充说明的是:如果在sql profile写入了完整的outline data,是可以固定执行计划的,比如将下面一个SQL完整的Hint的内容写入profile:
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.2.0.3')
DB_VERSION('11.2.0.3')
ALL_ROWS
OUTLINE_LEAF(@"SEL$1")
FULL(@"SEL
INDEX(@"SEL
LEADING(@"SEL
USE_NL(@"SEL
NLJ_BATCHING(@"SEL
END_OUTLINE_DATA
*/
这个profile是可以指定SQL使用哪个索引,表的关联方式和顺序。
结论:
sql profile到底能不能固定sql的执行计划?
答案是取决于你在profile中使用的hint组合是什么。使用完整的outline data内容就可以固定;使用不完整的,带有启发性的hint,就不会固定。
使用coe_sql_load_profile.sql脚本会固定你的SQL的执行计划(因为它写入profile中的内容的一个sql完整的outline data执行计划执行路径),除非遇到一些特殊情况,如索引不可用、并行资源不够、数据库相关参数变更等。
边栏推荐
猜你喜欢

Digital business cloud: build a digital supply chain system to enable enterprises to optimize and upgrade their logistics supply chain

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

Weizhi technology appeared in the Western Digital Expo, and the space-time AI technology was highly recognized

小甲鱼老师《带你学C带你飞》的后续课程补充

界面开发组件DevExpress ASP.NET Core v21.2 - UI组件增强

C #, introductory tutorial -- a little knowledge about function parameter ref and source program

结构型模式之适配器模式

Shell programming specification and variables

session机制详解以及session的相关应用

In the first half of the year, there were 7 new unicorns in this field, and the capital scrambled to enter the market
随机推荐
Interface development component devaxpress asp Net core v21.2 - UI component enhancements
自定义控件AutoScaleMode为Font造成宽度增加的问题
安装Office的一些工具
Digital commerce cloud: analyze the design idea of B2B2C multi-user mall system architecture, and open a new era of intelligent mall
插槽里如何判断text为数组
Human Pose Estimation浅述
Longest common subsequence
Decorator mode of structural mode
calendar控件编程
2年狂赚178亿元,中国游戏正在“收割”老外
故障分析 | 从 data_free 异常说起
Cluster, distributed and microservice concepts and differences
到底使用Thread还是Service?
shell脚本(五)——函数
ABAQUS 使用RSG绘制插件初体验
新唐NUC980使用记录:开发环境准备与编译配置基础说明
Flutter series -dart basic grammar learning
Shell script explanation (IV) -- while loop and until loop of loop statements (additional examples and analysis)
c# winform 嵌入flash
数组对象实现一 一对比(索引和id相同的保留原数据,原数组没有的数据从默认列表加进去)