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 SEPTEMBER 15, 2016

Applies to:

Oracle Database - Enterprise Edition - Version 11.1.0.6 to 11.2.0.3 [Release 11.1 to 11.2]
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 prdcableend.*
from prdcableend, prdcable, ienode, prdinstance
where ienode.siteId = <value>
and ienode.ienodeid = <value>
and ienode.ienodeId = prdcable.ienodeid
and prdcable.prdcableid = prdcableend.PrdcableId
and ( prdinstance.prdinstid = prdcableend.prdinstid or prdcableend.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 | PRDCABLEEND | 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 | IENODE | 1 | 14 | 2 | 00:00:01 |
| 6 | INDEX UNIQUE SCAN | XPKIENODE | 1 | | 1 | 00:00:01 |
| 7 | INDEX RANGE SCAN | XIE1PRDCABLE | 450 | 6300 | 4 | 00:00:01 |
| 8 | INDEX RANGE SCAN | XPKPRDCABLEEND| 2 | | 2 | 00:00:01 |
---------------------------------------------------------+-----------------------------------+

Cause

Sign In with your My Oracle Support account

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

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms