Oracle Forums
It is currently Fri Sep 10, 2010 7:07 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: which performs best? ansi join or oracle join?
PostPosted: Tue Mar 09, 2010 7:15 pm 
Offline

Joined: Thu Apr 02, 2009 7:41 am
Posts: 13
what is better performance wise between an ANSI join and an Oracle join?


Top
 Profile  
 
 Post subject: Re: which performs best? ansi join or oracle join?
PostPosted: Wed Mar 10, 2010 3:52 pm 
Offline

Joined: Fri Feb 13, 2009 11:37 am
Posts: 118
Well, some people say Oracle join is better and some say ANSI is better. However why not try to check the statements execution plan.
I have 2 statements that result the same output using ANSI and Oracle
Code:
SELECT   a.empno,
         a.ename,
         b.deptno,
         b.dname
  FROM   emp a, dept b
WHERE   a.deptno = b.deptno;

SELECT  empno,
         ename,
         deptno,
         dname
  FROM   emp  join dept
  using(deptno);

Now lets generate the Explain Plan
Code:
SQL> explain plan
  2  set statement_id='Oracle_Join'
  3  for
  4  SELECT   a.empno,
  5           a.ename,
  6           b.deptno,
  7           b.dname
  8    FROM   emp a, dept b
  9   WHERE   a.deptno = b.deptno;

Explained.

SQL> explain plan
  2  set statement_id='ANSI_Join'
  3  for
  4   SELECT  empno,
  5           ename,
  6           deptno,
  7           dname
  8    FROM   emp  join dept
  9    using(deptno);

Explained


Code:
SQL> select * from table(dbms_xplan.display('PLAN_TABLE','Oracle_Join','ALL'));

PLAN_TABLE_OUTPUT
Code:
                                                                                                                                                                                                   
                                                                                                         
| Id  | Operation             | Name          | Rows  | Bytes | Cost (%CPU)| Time     |                                                                                                                                                                                                                     
----------------------------------------------------------------------------------                                                                                                       
|   0 | SELECT STATEMENT      |               |    14 |   364 |     6   (0)| 00:00:01 |                                                                                                                                                                                                                     
|   1 |  NESTED LOOPS         |               |    14 |   364 |     6   (0)| 00:00:01 |                                                                                                                                                                                                                     
|   2 |   TABLE ACCESS FULL   | DEPT          |     4 |    52 |     3   (0)| 00:00:01 |                                                                                                                                                                                                                     
|   3 |   TABLE ACCESS CLUSTER| EMP           |     4 |    52 |     1   (0)| 00:00:01 |                                                                                                                                                                                                                     
|*  4 |    INDEX UNIQUE SCAN  | IDX_PERSONNEL |     1 |       |     0   (0)| 00:00:01 |                                                                                                                                                                                                                     
----------------------------------------------------------------------------------
SQL> select * from table(dbms_xplan.display('PLAN_TABLE','ANSI_Join'));                                                                                                                                                                                                                     
| Id  | Operation             | Name          | Rows  | Bytes | Cost (%CPU)| Time     |                                                                                                                                                                                                                     
----------------------------------------------------------------------------------                                                                                                                                                                                                                   
|   0 | SELECT STATEMENT      |               |    14 |   364 |     6   (0)| 00:00:01 |                                                                                                                                                                                                                     
|   1 |  NESTED LOOPS         |               |    14 |   364 |     6   (0)| 00:00:01 |                                                                                                                                                                                                                     
|   2 |   TABLE ACCESS FULL   | DEPT          |     4 |    52 |     3   (0)| 00:00:01 |                                                                                                                                                                                                                     
|   3 |   TABLE ACCESS CLUSTER| EMP           |     4 |    52 |     1   (0)| 00:00:01 |                                                                                                                                                                                                                     
|*  4 |    INDEX UNIQUE SCAN  | IDX_PERSONNEL |     1 |       |     0   (0)| 00:00:01 |                                                                                                                 

----------------------------------------------------------------------------------

I cannot see any difference in the Execution Plan..

_________________
Regards
Ozy
http://www.oraclevillage.com/


Top
 Profile  
 
 Post subject: Re: which performs best? ansi join or oracle join?
PostPosted: Thu Mar 11, 2010 12:16 pm 
Offline
Site Admin

Joined: Tue Feb 10, 2009 5:18 pm
Posts: 77
ANSI join certainly leads to cleaner SQL. IMO

_________________
Craig

Oracle APEX - http://www.oracleapplicationexpress.com


Top
 Profile  
 
 Post subject: Re: which performs best? ansi join or oracle join?
PostPosted: Sat Mar 13, 2010 5:59 pm 
Offline

Joined: Thu Apr 02, 2009 7:41 am
Posts: 13
thanks for the responses :D

i might focus on ANSI joins craig


Top
 Profile  
 
 Post subject: Re: which performs best? ansi join or oracle join?
PostPosted: Wed Mar 17, 2010 7:05 am 
Offline

Joined: Tue Mar 16, 2010 12:49 pm
Posts: 4
I like the ANSI join syntax because it enables me to separate the join conditions from the restrictions. With traditional syntax you have all together in the where clause...

_________________
iedge karte


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Template made by DEVPPL