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(@"SET2A13AF86_1" "T1"@"SET2A13AF86_1")

INDEX_RS_ASC(@"SET2A13AF86_2" "T1"@"SET2A13AF86_2" ("T1"."C"))

BATCH_TABLE_ACCESS_BY_ROWID(@"SET2A13AF86_2" "T1"@"SET2A13AF86_2")

END_OUTLINE_DATA

*/

相关推荐
NAGNIP3 小时前
大模型框架性能优化策略:延迟、吞吐量与成本权衡
算法
美团技术团队4 小时前
LongCat-Flash:如何使用 SGLang 部署美团 Agentic 模型
人工智能·算法
Fanxt_Ja8 小时前
【LeetCode】算法详解#15 ---环形链表II
数据结构·算法·leetcode·链表
侃侃_天下8 小时前
最终的信号类
开发语言·c++·算法
茉莉玫瑰花茶9 小时前
算法 --- 字符串
算法
博笙困了9 小时前
AcWing学习——差分
c++·算法
NAGNIP9 小时前
认识 Unsloth 框架:大模型高效微调的利器
算法
NAGNIP9 小时前
大模型微调框架之LLaMA Factory
算法
echoarts9 小时前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
Python技术极客9 小时前
一款超好用的 Python 交互式可视化工具,强烈推荐~
算法