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

*/

相关推荐
爱吃烤鸡翅的酸菜鱼几秒前
Java算法OJ(8)随机选择算法
java·数据结构·算法·排序算法
寻找码源43 分钟前
【头歌实训:利用kmp算法求子串在主串中不重叠出现的次数】
c语言·数据结构·算法·字符串·kmp
Matlab精灵44 分钟前
Matlab科研绘图:自定义内置多款配色函数
算法·matlab
诚丞成1 小时前
滑动窗口篇——如行云流水般的高效解法与智能之道(1)
算法
带多刺的玫瑰2 小时前
Leecode刷题C语言之统计不是特殊数字的数字数量
java·c语言·算法
爱敲代码的憨仔2 小时前
《线性代数的本质》
线性代数·算法·决策树
yigan_Eins3 小时前
【数论】莫比乌斯函数及其反演
c++·经验分享·算法
阿史大杯茶3 小时前
AtCoder Beginner Contest 381(ABCDEF 题)视频讲解
数据结构·c++·算法
დ旧言~3 小时前
【高阶数据结构】图论
算法·深度优先·广度优先·宽度优先·推荐算法
张彦峰ZYF3 小时前
投资策略规划最优决策分析
分布式·算法·金融