Home » RDBMS Server » Performance Tuning » Why Merge Cartesian Join
Why Merge Cartesian Join [message #159017] |
Wed, 15 February 2006 10:16  |
mjschwenger
Messages: 137 Registered: July 2005 Location: US
|
Senior Member |
|
|
I have a query which reports Merge Cartesian Join in the trace although I cannot explain why.
Thanks a lot for the help.
mj
SELECT er_state.*, er_history.sys_create_dt
FROM er_state, er_history
WHERE er_state.er_id = er_history.er_id
AND er_state.er_id = :1
AND er_state.ent_id = :2
CREATE INDEX IX_ER_STATE ON ER_STATE(ER_ID, ENT_ID,ACCT_ID);
ALTER TABLE ER_HISTORY ADD CONSTRAINT PK_ER_HISTORY_ID PRIMARY KEY(ER_ID) USING INDEX REVERSE;
Rows Row Source Operation
------- ---------------------------------------------------
1 MERGE JOIN CARTESIAN (cr=4 pr=0 pw=0 time=284 us)
1 TABLE ACCESS BY INDEX ROWID ER_STATE (cr=2 pr=0 pw=0 time=136 us)
1 INDEX RANGE SCAN IX_ER_STATE (cr=1 pr=0 pw=0 time=58 us)(object id 15946)
1 BUFFER SORT (cr=2 pr=0 pw=0 time=136 us)
1 TABLE ACCESS BY INDEX ROWID ER_HISTORY (cr=2 pr=0 pw=0 time=49 us)
1 INDEX UNIQUE SCAN PK_ER_HISTORY_ID (cr=1 pr=0 pw=0 time=26 us)(object id 15947)
|
|
|
|
|
|
|
Re: Why Merge Cartesian Join [message #159264 is a reply to message #159184] |
Fri, 17 February 2006 01:26  |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
Sorry Scot. Like so much of the nonsense that spouts from my keyboard, it is based on personal experience.
Like the OP, I first noticed Oracle doing CJs on me and panicked a bit (this was way back on 7.3!). I did some experimentation and - although a CJ with one table having 0 or 1 row is functionally very similar to a NL join, Oracle still prefers the CJ.
Note that a cartesian join is called "MERGE JOIN CARTESIAN" by the optimizer. This may be a clue. Perhaps internally it uses a different algorithm to the NL join that slighlty more efficient.
Honestly though, if you forced it to do a NL join with the 1-row table as the driving table, then I reckon you'd strugle to detect a performance difference.
_____________
Ross Leishman
[Updated on: Fri, 17 February 2006 01:27] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat May 03 04:24:42 CDT 2025
|