当前位置: 首页 > news >正文

opt_param 隐含参数修改

Sort MERGE join 排序合并

Goal

Query performs badly because of Sort-Merge Join.

When the pga_aggregate_target is increased, then the optimizer would favour for SM join which could be time consuming. So it is better to disable the SM join so that the optimizer would not favour SM joins in any circumstances.

SM Join can be disabled using the following parameter:

"_optimizer_sortmerge_join_enabled"

Solution

NOTE: In the images and/or the document content below, the user information and data used represents fictitious data from the Oracle sample schema(s) or Public Documentation delivered with an Oracle database product. Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner.

This parameter is available from 9.2.0 onwards. The value of the parameter is true by default. This parameter would make the optimizer to select the sort merge joins for SQL statement.

If the sort merge joins selected by the optimizer is consuming too much of resources and cpu time, then you can consider disabling the sort merge joins using the above said parameter.

Example:

SQL> explain plan for select  a.empno,a.ename,b.deptno from emp a , dept b where a.deptno<b.deptno;

---------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 3 | 48 | 7 |
| 1 | MERGE JOIN | | 3 | 48 | 7 |
| 2 | SORT JOIN | | 4 | 12 | 1 |
| 3 | INDEX FULL SCAN | PK_DEPT | 4 | 12 | 1 |
|* 4 | SORT JOIN | | 14 | 182 | 6 |
| 5 | TABLE ACCESS FULL| EMP | 14 | 182 | 2 |
---------------------------------------------------------------

The presence of sort merge joins for a query is found in the execution plan with sort join and merge join sort join 中的join是不是多了, sort merge join  排序合并   in the explain plan output.

This can be disabled at system level or session level.

i ) Disabling the sort merge join at system level

SQL> alter system set "_optimizer_sortmerge_join_enabled"=false;

Note: This can be done only from 10g onwards. Prior to 10g , the parameter has to be modified in init.ora and requires database bounce back.

SQL> explain plan for select a.empno,a.ename,b.deptno from emp a , dept b where a.deptno<b.deptno;

------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 3 | 48 | 4 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 3 | 48 | 4 (0)| 00:00:01 |
| 2 | TABLE ACCESS FULL| EMP | 14 | 182 | 3 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | PK_DEPT | 1 | 3 | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------

ii ) Disabling the sort merge join using hints

SQL> explain plan for select /*+ opt_param('_optimizer_sortmerge_join_enabled','false') */ a.empno,a.ename,b.deptno from emp a , dept b where a.deptno<b.deptno; 

------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 3 | 48 | 4 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 3 | 48 | 4 (0)| 00:00:01 |
| 2 | TABLE ACCESS FULL| EMP | 14 | 182 | 3 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | PK_DEPT | 1 | 3 | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------

Note: This can be done only from 10g onwards. Prior to 10g, there is no any hints like opt_param.

http://www.dtcms.com/a/296416.html

相关文章:

  • Webpack/Vite 终极指南:前端开发的“涡轮增压引擎“
  • 深入理解 IO 多路复用:从 select 到 epoll
  • CTFshow-PWN-栈溢出(pwn67-pwn68)nop sled 空操作雪橇-对抗栈帧地址随机化
  • 数字化转型-埃森哲集团数字化顶层规划
  • SQL中的占位符、@Param注解和方法参数
  • vue递归树形结构删除不符合数据 生成一个新数组
  • HTTPS如何保障安全?详解证书体系与加密通信流程
  • AI 在金融:重塑金融服务的智能革命
  • 《小白学习产品经理》第十章:方法论之MVP
  • Windows 下配置 GPU 用于深度学习(PyTorch)的完整流程
  • 让复杂 AI 应用构建就像搭积木:Spring AI Alibaba Graph 使用指南与源码解读
  • 测试学习之——Pytest Day5
  • 关闭 Chrome 浏览器后,自动删除浏览历史记录
  • 3.7 综合挑战项目
  • C语言(长期更新)第5讲:数组练习(三)
  • 跑步有氧训练
  • MegaTTS3 使用
  • Elasticsearch 的聚合(Aggregations)操作详解
  • Mysql窗口函数
  • 数据库垂直拆分和水平拆分
  • 面经 - 车载多媒体系统
  • 【已解决】YOLO11模型转wts时报错:PytorchStreamReader failed reading zip archive
  • PyTorch数据选取与索引详解:从入门到高效实践
  • es 和 lucene 的区别
  • 【REACT18.x】CRA+TS+ANTD5.X实现useImperativeHandle让父组件修改子组件的数据
  • R study notes[1]
  • linux入门 相关linux系统操作命令(二)--文件管理系统 ubuntu22.04
  • 二分查找-153-寻找旋转排序数组中的最小值-力扣(LeetCode)
  • unordered_map和unordered_set特性以及解决哈希冲突
  • Gemini拿下IMO2025金牌的提示词解析