Identify OR Expansion in An Explain Plan OR_EXPAND 自动转化成union all

Goal

This note helps you identify OR expansion in an explain plan.

Solution

Legacy OR was a heuristic. The new cost-based OR expansion is costed; there are cases where it will kick in when it didn't before, and visa-versa.

  • Pre-12.2, you will see CONCATENATION in the plan.

  • For 12.2 and onwards, you will see UNION-ALL in the plan.

  • You should see OR_EXPAND in the Outline data

Here is an example in 19c:
--------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
--------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 131 (100)| | | |
| 1 | VIEW | VW_ORE_BA8ECEFB | 1100 | 14300 | 131 (1)| 00:00:01 | | | <----- VW_ORE_<string> may be a clue, as well
| 2 | UNION-ALL | | | | | | | | <-----
| 3 | PARTITION HASH SINGLE | | 1000 | 9000 | 22 (5)| 00:00:01 | 2 | 2 |
|* 4 | TABLE ACCESS FULL | T1 | 1000 | 9000 | 22 (5)| 00:00:01 | 2 | 2 |
| 5 | PARTITION HASH ALL | | 100 | 1300 | 109 (0)| 00:00:01 | 1 | 8 |
|* 6 | TABLE ACCESS BY LOCAL INDEX ROWID BATCHED| T1 | 100 | 1300 | 109 (0)| 00:00:01 | 1 | 8 |
|* 7 | INDEX RANGE SCAN | CI | 100 | | 9 (0)| 00:00:01 | 1 | 8 |
--------------------------------------------------------------------------------------------------------------------------------

Outline Data

-------------

/*+

BEGIN_OUTLINE_DATA

IGNORE_OPTIM_EMBEDDED_HINTS

OPTIMIZER_FEATURES_ENABLE('19.1.0')

DB_VERSION('19.1.0')

ALL_ROWS

OUTLINE_LEAF(@"SET$2A13AF86_2")

OUTLINE_LEAF(@"SET$2A13AF86_1")

OUTLINE_LEAF(@"SET$2A13AF86")

OUTLINE_LEAF(@"SEL$9162BF3C")

OR_EXPAND(@"SEL$1" (1) (2)) <-----

OUTLINE(@"SEL$1")

NO_ACCESS(@"SEL9162BF3C" "VW_ORE_BA8ECEFB"@"SELBA8ECEFB")

FULL(@"SET$2A13AF86_1" "T1"@"SET$2A13AF86_1")

INDEX_RS_ASC(@"SET$2A13AF86_2" "T1"@"SET$2A13AF86_2" ("T1"."C"))

BATCH_TABLE_ACCESS_BY_ROWID(@"SET$2A13AF86_2" "T1"@"SET$2A13AF86_2")

END_OUTLINE_DATA

*/

相关推荐
西几1 小时前
代码训练营 day48|LeetCode 300,LeetCode 674,LeetCode 718
c++·算法·leetcode
liuyang-neu1 小时前
力扣第420周赛 中等 3324. 出现在屏幕上的字符串序列
java·算法·leetcode
想做白天梦2 小时前
双向链表(数据结构与算法)
java·前端·算法
小卡皮巴拉2 小时前
【力扣刷题实战】相同的树
c语言·算法·leetcode·二叉树·递归
zyhomepage2 小时前
科技的成就(六十四)
开发语言·人工智能·科技·算法·内容运营
想做白天梦2 小时前
多级反馈队列
java·windows·算法
潇雷2 小时前
算法Day12|226-翻转二叉树;101-对称二叉树;104-二叉树最大深度;111-二叉树最小深度
java·算法·leetcode
爱编程— 的小李3 小时前
开关灯问题(c语言)
c语言·算法·1024程序员节
韭菜盖饭3 小时前
LeetCode每日一题3211---生成不含相邻零的二进制字符串
数据结构·算法·leetcode
极客代码3 小时前
C/C++ 随机数生成方法
c语言·开发语言·c++·算法