Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Tuning question
Dan (daniel.ostertag_at_visaer.com) wrote:
: Another question. I'm trying to find out the most efficient way to
: join multiple tables. Take a situation in which you are joining
: multiple tables on the same field. Is it better to join table1 to
: table2 then table2 to table3 like below:
: select TABLE1.partno from TABLE1, TABLE2, TABLE3
: where table1.partno = table2.partno and
: table2.partno = table3.partno;
: Or is it better to join all from the table1 field, like below:
: select TABLE1.partno from TABLE1, TABLE2, TABLE3
: where table1.partno = table2.partno and
: table1.partno = table3.partno;
: I did a quick explain plan and scenario #2 showed a lower cost but I
: don't know if that's because of my data or not. I saw a book example
: which used scenario #1. Can I make a hard and fast rule on this type
: of thing, or does it depend on the data, the driving table, etc?
Though I don't see it makes a difference here, you should remember that some columns may contains NULLs, and if an outer join were used then the two examples might not be equivalent. Received on Thu Oct 20 2005 - 17:59:46 CDT