My Oracle Support Banner

Poor Performance for Query Using a Join in an OR Clause with Execution Plan Showing MERGE JOIN CARTESIAN Operation (Doc ID 1429323.1)

Last updated on FEBRUARY 14, 2019

Applies to:

Oracle Database - Enterprise Edition - Version 11.1.0.6 to 11.2.0.3 [Release 11.1 to 11.2]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Information in this document applies to any platform.

Symptoms

The following query that ran quickly in 10g is taking hours to complete in 11g, spending most of the  time on CPU:

Select Distinct t1.*
from t1, t2, t3, T4
where t3.siteId = <value>
and t3.t3id = <value>
and t3.t3Id = t2.t3id
and t2.t2id = t1.t2Id
and ( T4.prdinstid = t1.prdinstid or t1.prdinstid is null)



The execution plan in 11g shows en extremely high number of rows being returned and time spent on MERGE JOIN CARTESIAN:

----------------------------------------------------------+-----------------------------------+
| Id  | Operation                         | Name          | Rows  | Bytes | Cost  | Time      |
----------------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT                  |               |       |       |  306M |           |
| 1   |  HASH UNIQUE                      |               |   12G |  962G |  306M |1069:28:34 |
| 2   |   CONCATENATION                   |               |       |       |       |           |
| 3   |    MERGE JOIN CARTESIAN           |               |   12G |  904G | 9810K |  33:29:09 |
| 4   |     HASH JOIN                     |               |  6907 |  472K |  1258 |  00:00:16 |
| 5   |      NESTED LOOPS                 |               |   16K |  438K |    59 |  00:00:01 |
.....
| 12  |    HASH JOIN                      |               |   19K | 1431K |  4497 |  00:00:54 |
| 13  |     HASH JOIN                     |               |   19K | 1301K |  1242 |  00:00:15 |
..... 

The 10g plan does not show a MERGE JOIN CARTESIAN operation:

---------------------------------------------------------+-----------------------------------+
| Id | Operation | Name | Rows | Bytes | Cost | Time |
---------------------------------------------------------+-----------------------------------+
| 0 | SELECT STATEMENT | | | | 1359 | |
| 1 | HASH UNIQUE | | 622 | 49K | 1359 | 00:00:17 |
| 2 | TABLE ACCESS BY INDEX ROWID | T1 | 1 | 52 | 3 | 00:00:01 |
| 3 | NESTED LOOPS | | 622 | 49K | 1358 | 00:00:17 |
| 4 | NESTED LOOPS | | 450 | 12K | 6 | 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID | T3 | 1 | 14 | 2 | 00:00:01 |
| 6 | INDEX UNIQUE SCAN | XPKT3 | 1 | | 1 | 00:00:01 |
| 7 | INDEX RANGE SCAN | XIE1T2 | 450 | 6300 | 4 | 00:00:01 |
| 8 | INDEX RANGE SCAN | XPKT1| 2 | | 2 | 00:00:01 |
---------------------------------------------------------+-----------------------------------+

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.