| Author |
Topic |
|
carumuga
Posting Yak Master
174 Posts |
Posted - 2009-02-03 : 04:15:27
|
| Hi,I have two tables, Emp and EmpDetail, connected by using PK-FK.What is the right way to join the table to get optimize result.That is, Is it right the join Emp.EmpID = EmpDetail.EmpIDorEmpDetail.EmpID = Emp.EmpIDWhat i'm trying to post is, the better way to match the records by the concept of small table vs large table. One of my architect explained that try to related tables with large table with small table. (large table in the left hand side of the INNER JOIN).Please advise. |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-03 : 04:19:06
|
| there will be no problem in inner join for to get the records (it will see that matched records will be displayed)select e.col1,e.col2,e1.col1,.....(required columns)from emp e inner join empdetails e1 on e1.empid = e.empid |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2009-02-03 : 04:24:39
|
| the order of tables for an inner join is not importantEm |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-03 : 04:30:17
|
| Its work fine either join with Emp.EmpID = EmpDetail.EmpIDorEmpDetail.EmpID = Emp.EmpID |
 |
|
|
AvanthaSiriwardana
Yak Posting Veteran
78 Posts |
Posted - 2009-02-03 : 04:43:33
|
| But in order to optimize the query, you may first get the table which the data load is lower than the other table and then join it.Avantha SiriwardanaBeware of bugs in the above code; I have only proved it correct, not tried it. (Donald Knuth) |
 |
|
|
carumuga
Posting Yak Master
174 Posts |
Posted - 2009-02-03 : 04:51:46
|
| Can i take it granted that there is no concept of large table joined with small table for optimizing? |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2009-02-03 : 05:00:03
|
| either way round, the execution plan is the sameEm |
 |
|
|
AvanthaSiriwardana
Yak Posting Veteran
78 Posts |
Posted - 2009-02-03 : 05:16:48
|
| All these concepts will base on the table which you gonna select data..but my concern is, there is a impact when you use the above concept...:)Avantha SiriwardanaBeware of bugs in the above code; I have only proved it correct, not tried it. (Donald Knuth) |
 |
|
|
rhysmeister
Starting Member
6 Posts |
|
|
|