当前位置:网站首页>no_ Expand and use_ concat
no_ Expand and use_ concat
2022-06-26 00:11:00 【Document Porter】
RDBMS: Database Release Update Revision : 19.11.2.0.211019 (33153989)
Reference documents :
(4 Bar message ) Query conversion or expansion_ Document Porter -CSDN Blog
Query Transformations (oracle.com)
In OR expansion, the optimizer transforms a query block containing top-level disjunctions into the form of a UNION ALL query that contains two or more branches. The optimizer achieves this goal by splitting the disjunction into its components, and then associating each component with a branch of a UNION ALL query.
The optimizer can choose OR expansion for various reasons. For example, it may enable more efficient access paths or alternative join methods that avoid Cartesian products. As always, the optimizer performs the expansion only if the cost of the transformed statement is lower than the cost of the original statement.
In previous releases, the optimizer used the CONCATENATION operator to perform the OR expansion. Starting in Oracle Database 12c Release 2 (12.2), the optimizer uses the UNION-ALL operator instead. The framework provides the following enhancements:
Enables interaction among various transformations
Avoids sharing query structures
Enables the exploration of various search strategies
Provides the reuse of cost annotation
Supports the standard SQL syntax
-- About these two hint Explanation
USE_CONCAT - The USE_CONCAT hint forces combined OR conditions in the WHERE clause of a query to be transformed into a compound query using the UNION ALL set operator. Generally, this transformation occurs only if the cost of the query using the concatenations is cheaper than the cost without them.
NO_EXPAND - The NO_EXPAND hint prevents the cost-based optimizer from considering OR-expansion for queries having OR conditions or IN-lists in the WHERE clause. Usually, the optimizer considers using OR expansion and uses this method if it decides that the cost is lower than not using it.
-- test :
-- where There is... In the condition or, The optimizer uses union all
[email protected]>SELECT *
2 FROM hr.employees e, hr.departments d
3 WHERE (e.email='SSTILES' OR d.department_name='Treasury')
4 AND e.department_id = d.department_id;
Execution Plan
----------------------------------------------------------
Plan hash value: 2462079978
----------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 11 | 2079 | 6 (0)| 00:00:01 |
| 1 | VIEW | VW_ORE_19FF4E3E | 11 | 2079 | 6 (0)| 00:00:01 |
| 2 | UNION-ALL | | | | | |
| 3 | NESTED LOOPS | | 1 | 90 | 2 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID| EMPLOYEES | 1 | 69 | 1 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | EMP_EMAIL_UK | 1 | | 0 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID| DEPARTMENTS | 1 | 21 | 1 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | DEPT_ID_PK | 1 | | 0 (0)| 00:00:01 |
| 8 | NESTED LOOPS | | 10 | 900 | 4 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 10 | 900 | 4 (0)| 00:00:01 |
|* 10 | TABLE ACCESS FULL | DEPARTMENTS | 1 | 21 | 3 (0)| 00:00:01 |
|* 11 | INDEX RANGE SCAN | EMP_DEPARTMENT_IX | 10 | | 0 (0)| 00:00:01 |
|* 12 | TABLE ACCESS BY INDEX ROWID| EMPLOYEES | 10 | 690 | 1 (0)| 00:00:01 |
----------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
5 - access("E"."EMAIL"='SSTILES')
7 - access("E"."DEPARTMENT_ID"="D"."DEPARTMENT_ID")
10 - filter("D"."DEPARTMENT_NAME"='Treasury')
11 - access("E"."DEPARTMENT_ID"="D"."DEPARTMENT_ID")
12 - filter(LNNVL("E"."EMAIL"='SSTILES'))
Note
-----
- this is an adaptive plan
Statistics
----------------------------------------------------------
156 recursive calls
0 db block gets
146 consistent gets
9 physical reads
0 redo size
1760 bytes sent via SQL*Net to client
510 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
7 sorts (memory)
0 sorts (disk)
1 rows processed
[email protected]>-- add hint no_expand , Found that he didn't go union all 了 . from Statistics Look up , Cycle call , Consistent read , Sort , A lot less .
SELECT /*+ NO_EXPAND */ *
FROM hr.employees e, hr.departments d
WHERE (e.email='SSTILES' OR d.department_name='Treasury')
AND e.department_id = d.department_id;
[email protected]>SELECT /*+ NO_EXPAND */ *
2 FROM hr.employees e, hr.departments d
3 WHERE (e.email='SSTILES' OR d.department_name='Treasury')
4 AND e.department_id = d.department_id;
Execution Plan
----------------------------------------------------------
Plan hash value: 413710308
--------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 5 | 450 | 6 (17)| 00:00:01 |
| 1 | MERGE JOIN | | 5 | 450 | 6 (17)| 00:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID| DEPARTMENTS | 27 | 567 | 2 (0)| 00:00:01 |
| 3 | INDEX FULL SCAN | DEPT_ID_PK | 27 | | 1 (0)| 00:00:01 |
|* 4 | FILTER | | | | | |
|* 5 | SORT JOIN | | 107 | 7383 | 4 (25)| 00:00:01 |
| 6 | TABLE ACCESS FULL | EMPLOYEES | 107 | 7383 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - filter("E"."EMAIL"='SSTILES' OR "D"."DEPARTMENT_NAME"='Treasury')
5 - access("E"."DEPARTMENT_ID"="D"."DEPARTMENT_ID")
filter("E"."DEPARTMENT_ID"="D"."DEPARTMENT_ID")
Statistics
----------------------------------------------------------
8 recursive calls
0 db block gets
12 consistent gets
0 physical reads
0 redo size
1760 bytes sent via SQL*Net to client
527 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed
[email protected]>END
边栏推荐
猜你喜欢

10.2.3、Kylin_kylin的使用,维度必选

ValueError: color kwarg must have one color per data set. 9 data sets and 1 colors were provided解决

安装PSU的时候/usr/bin/ld:warning: -z lazyload ignore

Studio5k V28 installation and cracking_ Old bear passing by_ Sina blog

文献调研(三):数据驱动的建筑能耗预测模型综述

被新冠后遗症困住15个月后,斯坦福学霸被迫缺席毕业典礼,现仍需每天卧床16小时:我本该享受20岁的人生啊...

yolov5 提速多GPU训练显存低的问题

正则表达式介绍及一些语法

mysql 主从复制

MySQL master-slave replication
随机推荐
oracle RAC 集群无法启动
MySQL master-slave replication
Given the parameter n, there will be n integers 1, 2, 3,... From 1 to n, n. These n arrays have n! An arrangement that lists all columns in ascending order of size and marks them one by one. Given n a
Thrift入门学习
《网络是怎么样连接的》读书笔记 - 集线器、路由器和路由器(三)
Recherche documentaire (3): examen des modèles de prévision de la consommation d'énergie des bâtiments fondés sur les données
正则表达式介绍及一些语法
Thrift getting started
手工制作 pl-2303hx 的USB轉TTL電平串口的電路_過路老熊_新浪博客
深圳台电:联合国的“沟通”之道
2021-04-28
网络协议之:redis protocol详解
电路板去板边—V-Cut分板机注意事项
Literature research (I): hourly energy consumption prediction of office buildings based on integrated learning and energy consumption pattern classification
Transformation of communication protocol between Siemens S7-200PLC and Danfoss inverter_ Old bear passing by_ Sina blog
redux工作流程+小例子的完整代码
Read CSV file data in tensorflow
smt贴片加工行业pcba常见测试方法优劣分析比较
(转载)进程和线程的形象解释
Find the minimum value of flipped array [Abstract bisection]