Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
asafg
Starting Member
39 Posts |
Posted - 2008-11-17 : 02:52:00
|
Hi.My supervisor ask me to use inner join and not left join because it is faster. (always)I have written a script in which the left join run much faster.He seems to be very sure in what he tells me.can you tell me the real difference between the two?ThanksAsaf |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-17 : 03:20:14
|
inner join works faster than left join.Inner join basically returns records which satisfy matching criteria given on on condition between left and right side queries.Left join returns all records from left query regardless of whether it matches right side on given condition. In cases where it matches, it returns matching values and in other cases it returns null. |
 |
|
asafg
Starting Member
39 Posts |
Posted - 2008-11-17 : 03:43:48
|
OK, I understandbut still I had a query in which there was a huge difference between the two the left join took a few seconds and the inner join took several minutes:Is it possible that when I have two tables - one very small 100 records and the second is big 300K records a left join from the 100 record table will work faster?this is the only thing that I can think, that made the left join faster |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-17 : 04:19:22
|
there are various other factors you should consider like any where conditions used in query what ll indexes were present on table etc. Analysing the executio plan in both cases might give you some idea on why difference in execution time. |
 |
|
|
|
|