当前位置:网站首页>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
边栏推荐
- 详细讲解局部变量、全局变量、静态变量三种类型
- Smt贴片机保养与维护要点
- 解决线程并发安全问题
- Redis memory elimination mechanism
- Redis之哨兵
- Smt贴片加工出现元件立碑的解决方法
- 什么是微服务
- Network protocol: detailed explanation of redis protocol
- Establishment of multiple background blocks in botu software_ Old bear passing by_ Sina blog
- Transformation of communication protocol between Siemens S7-200PLC and Danfoss inverter_ Old bear passing by_ Sina blog
猜你喜欢

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

Lazy people teach you to use kiwi fruit to lose 16 kg in a month_ Old bear passing by_ Sina blog

Studio5k V28 installation and cracking_ Old bear passing by_ Sina blog
![[wechat official account H5] generates a QR code with parameters to enter the official account attention page to listen to user-defined menu bar for official account events (server)](/img/d9/935bad29005e5846dc514c966e3b0e.png)
[wechat official account H5] generates a QR code with parameters to enter the official account attention page to listen to user-defined menu bar for official account events (server)

10.4.1、数据中台

(Reprint) visual explanation of processes and threads

About Simple Data Visualization

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

EasyConnect连接后显示未分配虚拟地址

Literature research (I): hourly energy consumption prediction of office buildings based on integrated learning and energy consumption pattern classification
随机推荐
详细讲解局部变量、全局变量、静态变量三种类型
使用coe_load_sql_profile.sql固定执行计划
14.1.1、Promethues监控,四种数据类型metrics,Pushgateway
6. common instructions (upper) v-cloak, v-once, v-pre
JS to input the start time and end time, output the number of seasons, and print the corresponding month and year
Search rotation array ii[Abstract dichotomy exercise]
10.4.1 data console
PCB生产为什么要做拼板和板边
Keil compilation run error, missing error: # 5: # includecore_ cm3.h_ Old bear passing by_ Sina blog
记录一些cf的题
Smt贴片机工作流程
Mysql5.7.31自定义安装详细说明
How postman tests interfaces that require login
Sword finger offer 48 Longest substring without duplicate characters
ffmpeg 版本切换
POSTMAN测试出现SSL无响应
快手实时数仓保障体系研发实践
Hand made pl-2303hx USB to TTL level serial port circuit_ Old bear passing by_ Sina blog
DHCP review
redis之集群