need help to understand this execution plan [message #543249] |
Mon, 13 February 2012 13:36 |
|
n2fontenay
Messages: 15 Registered: December 2011 Location: San Diego, CA
|
Junior Member |
|
|
Hi,
I got this query:
SELECT
c.id DTVContentId,
c.Channel,
c.SiteID,
c.OutputURL,
ea.name EncryptionAppliance,
k.Key1,
k.Key2,
k.KeyStartTime,
k.KeyEndTime,
k.Expired,
k.EncryptionFlag,
k.Imported,
k.RemoteKey2EndTime
FROM iptv.DTVContent c
JOIN iptv.DTVKey k
ON k.DTVContentId = c.Id
JOIN iptv.ContentAppliance ca
ON ca.ContentId = k.DTVContentId
JOIN iptv.EncryptionAppliance ea
ON ea.id = ca.EncryptionApplianceId
WHERE k.Expired = 0
and c.active = 1
and c.channel is not null;
and then I got this execution plan:
Can someone help me understand where is the cartesian operation in that query, and why?
-----------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2867 | 347K| 33 (7)| 00:00:01 |
| 1 | NESTED LOOPS | | 2867 | 347K| 33 (7)| 00:00:01 |
|* 2 | HASH JOIN | | 2000 | 228K| 32 (4)| 00:00:01 |
|* 3 | TABLE ACCESS FULL | DTVCONTENT | 1999 | 75962 | 9 (0)| 00:00:01 |
| 4 | MERGE JOIN CARTESIAN | | 2000 | 154K| 22 (0)| 00:00:01 |
| 5 | VIEW | index$_join$_006 | 1 | 9 | 3 (0)| 00:00:01 |
|* 6 | HASH JOIN | | | | | |
| 7 | INDEX FAST FULL SCAN| IX_ENCRYPTIONAPPLIANCE_NAME | 1 | 9 | 1 (0)| 00:00:01 |
| 8 | INDEX FAST FULL SCAN| PK_ENCRYPTIONAPPLIANCE | 1 | 9 | 1 (0)| 00:00:01 |
| 9 | BUFFER SORT | | 2000 | 136K| 19 (0)| 00:00:01 |
|* 10 | TABLE ACCESS FULL | DTVKEY | 2000 | 136K| 19 (0)| 00:00:01 |
|* 11 | INDEX UNIQUE SCAN | PK_CONTENTAPPLIANCE | 1 | 7 | 0 (0)| 00:00:01 |
-----------------------------------------------------------------
[Updated on: Mon, 13 February 2012 13:43] Report message to a moderator
|
|
|
|
|
|
Re: need help to understand this execution plan [message #543266 is a reply to message #543252] |
Mon, 13 February 2012 16:25 |
cookiemonster
Messages: 13962 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
The first query is joining two indexes: IX_ENCRYPTIONAPPLIANCE_NAME and PK_ENCRYPTIONAPPLIANCE. It thinks that join will give 1 row, so it then does a merge join cartesian between the result of that join and DTVKEY.
Merge Join cartesian isn't always a problem.
The 2nd query is different because the extra columns in the select list means it has to access all four tables where previously it could avoid hitting CONTENTAPPLIANCE and ENCRYPTIONAPPLIANCE as all the columns it needed were covered by indexes.
|
|
|
Re: need help to understand this execution plan [message #543738 is a reply to message #543249] |
Thu, 16 February 2012 10:51 |
S.Rajaram
Messages: 1027 Registered: October 2006 Location: United Kingdom
|
Senior Member |
|
|
You have missed the most important point in your plan which is the predicate section. Sometimes predicate section will enlighten you why oracle is not using an Index and why it has chosen a particular path.
Firstly I would check whether my stats are upto date (the most boring step).
Second, I would compare my row source estimates between the actual and the estimated. If they are way apart need to dig in further to find out why CBO cannot come up with the estimate and how can I help it to come up with it.
But either way compare the execution plan between different sql and also remember to post the predicate section of your output.
Thanks
Raj
|
|
|