深入SQL执行计划之CBO查询转换(7):Distinct 配置最优机能(Distinct Placement)
2023-06-13 09:11:17 时间
编者按:
本文作者系杨昱明,现就职于甲骨文公司,从事数据库方面的技术支持。希望能通过发表文章,把一些零散的知识再整理整理。个人主页:https://blog.csdn.net/weixin_50513167,经其本人授权发布。
【免责声明】本号文章仅代表个人观点,与任何公司无关。
编辑|SQL和数据库技术(ID:SQLplusDB)
CBO 查询转换系列(深入了解Oracle执行计划)
CBO 查询转换(1):子查询展开机能(Subquery Unnesting)
CBO 查询转换(2):反结合的NULL识别机能(null aware anti-join )
CBO 查询转换(3):结合谓词下推机能(Join Predicate Pushdown)
CBO 查询转换 (4):Group By 配置最优机能(Group By Placement)
CBO查询转换(5):星型转换(Star Transformation)
CBO查询转换(6):子查询关联集展开机能(unnest correlation set subquery)
同之前聊过的 Group By 配置最优机能同等的,还有 Distinct 配置最优机能(Distinct Placement)。
还是用下面的 Test case 进行简单的演示,说明一下 Distinct Placement 动作时执行计划的样子。
drop table t1 purge;
drop table t2 purge;
create table t1(c1 number, c2 number not null);
create table t2(c1 number, c2 number not null);
insert into t1 values (1,1);
insert into t1 values (1,2);
insert into t1 values (2,2);
insert into t2 values (1,2);
commit;
SQL> SQL> select /*+ place_distinct(t2) */
distinct t1.c2, t2.c2
from t1, t2
where t1.c1 = t2.c1; 2 3 4
C2 C2
---------- ----------
1 2
2 2
Execution Plan
----------------------------------------------------------
Plan hash value: 107983552
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 104 | 8 (25)| 00:00:01 |
| 1 | HASH UNIQUE | | 2 | 104 | 8 (25)| 00:00:01 |
|* 2 | HASH JOIN | | 2 | 104 | 7 (15)| 00:00:01 |
| 3 | VIEW | VW_DTP_AE9E49E8 | 1 | 26 | 4 (25)| 00:00:01 |
| 4 | HASH UNIQUE | | 1 | 26 | 4 (25)| 00:00:01 |
| 5 | TABLE ACCESS FULL| T2 | 1 | 26 | 3 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | T1 | 3 | 78 | 3 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("T1"."C1"="ITEM_1")
Note
-----
- dynamic sampling used for this statement (level=2)
特征是使用了内部转换的试图 VW_DTP_*。
关闭此功能的方法是 "_optimizer_distinct_placement" = false。
相关文章
- 电压电流转换电路[通俗易懂]
- SQL数据库字符串与时间相互转换「建议收藏」
- h3c路由器配置nat转换命令_路由器nat地址转换配置
- 使用postcss-plugin-px2rem和postcss-pxtorem(postcss-px2rem)-px自动转换rem的配置方法-vue-cli3.0
- Linux shell 执行报错 字符编码转换 iconv/dos2unix 将 gbk/gb2312 转utf8 解决方案
- 2022 DBA 角色转换 挑战 与 机遇
- Python_ASCII码和进制进行转换练习_Python自学第十二节
- 算法练习之将有序数组转换为二叉搜索树,平衡二叉树详解编程语言
- 转换Oracle SQL中的类型转换:技巧与实现(oraclesql类型)
- 新闻速读 > Facebook 的 TransCoder AI 可在 Java、Python 和 C++ 之间转换代码
- 老虎证券七周年丨道朴资本王红欣:应配置不同驱动力、赚钱机制及系统风险下的资产来对冲牛熊转换
- 如何通过配置自动实现ValueList中hql语句的整型参数转换