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
*/