Home » SQL & PL/SQL » SQL & PL/SQL » Advantages of Order of Tables in "FROM " Clause
Advantages of Order of Tables in "FROM " Clause [message #623099] Thu, 04 September 2014 07:41 Go to next message
mastansky@gmail.com
Messages: 13
Registered: July 2013
Location: INDIA
Junior Member

Hi ,

May I know the difference between the following Syntax and how the order of table in the FROM Clause effects the performance and how to calculation ,Can anyone share their ideas .

SELECT
EMP.Ename,
DEPT.Dname
FROM
EMP,DEPT<-------------------------------Order of the tables
WHERE
EMP.Deptno=DEPT.Deptno;

---------------------------------------
SELECT
EMP.Ename,
DEPT.Dname
FROM
DEPT,DEPT<------------------------------Order of tables
WHERE
EMP.Deptno=DEPT.Deptno;


Thanks In Advance.

[Updated on: Thu, 04 September 2014 07:43]

Report message to a moderator

Re: Advantages of Order of Tables in "FROM " Clause [message #623100 is a reply to message #623099] Thu, 04 September 2014 07:43 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Well, the second piece of code would fail, but to the question, the order of the tables is irrelevant, Oracle will work that out for you.
Re: Advantages of Order of Tables in "FROM " Clause [message #623101 is a reply to message #623099] Thu, 04 September 2014 07:49 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Guess it is a typo in your 2nd query. Perhaps you meant, DEPT, EMP. But does it matter? No. As CM said, oracle handles it. The CBO is smart enough you know. You can check it yourself. Just look at the execution plan. Well, there are ways to force the optimizer to change the order via hint, however it is out of the scope of your question.
Re: Advantages of Order of Tables in "FROM " Clause [message #623102 is a reply to message #623099] Thu, 04 September 2014 07:49 Go to previous messageGo to next message
mastansky@gmail.com
Messages: 13
Registered: July 2013
Location: INDIA
Junior Member

Sorry ,The second SELECT Statement Order of The table is DEPT,EMP.
Re: Advantages of Order of Tables in "FROM " Clause [message #623107 is a reply to message #623102] Thu, 04 September 2014 09:34 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
The order of the tables mattered in Oracle 8i and below because it used the rule based optimizer (RBO), but since oracle started using the cost based optimizer (CBO) in oracle 9 it doesn't matter as long as you have statistics.
Re: Advantages of Order of Tables in "FROM " Clause [message #623108 is a reply to message #623107] Thu, 04 September 2014 10:03 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and read http://www.orafaq.com/forum/t/174502/
Re: Advantages of Order of Tables in "FROM " Clause [message #623110 is a reply to message #623099] Thu, 04 September 2014 10:29 Go to previous message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Exceptionally, when you have many tables inline views, you can put the in order you want they'll be taken into account by the optimizer and use the ORDERED hint to inform Oracle you do so.

Previous Topic: CHMOD FROM A PLSQL?
Next Topic: Update trigger (merged 2)
Goto Forum:
  


Current Time: Fri Apr 26 16:06:48 CDT 2024