I did a comparison for you with real numbers. The execution plans are the same except on B, there is an extra Compute Scalar. This is for tables WITH NO INDEXES.-- Generate Test Data-- Make the Column of Inerest different data for each-- And TableOne have more data than TableTwoSET STATISTICS IO OffSET STATISTICS TIME OffDrop Table #TableOneDrop Table #TableTwoCreate Table #TableOne (id int, ColumnOfInterest varchar(50))Create Table #TableTwo (id int, ColumnOfInterest varchar(50))Declare @cnt intSet @cnt = 0While @cnt < 1000000 Begin Insert Into #TableOne Select @cnt, NewID() If @cnt % 4 = 0 Insert Into #TableTwo Select @cnt, NewID() Set @cnt = @cnt + 1End
Now I run my tests.--Turn statistics on so you can see how each performsSET STATISTICS IO ONSET STATISTICS TIME ON--Run this before every query execution so you get accurate resultsDBCC DROPCLEANBUFFERSDBCC FREEPROCCACHESelectT1.ColumnOfInterest, T2.ColumnOfInterestFrom#TableOne T1Left Join #TableTwo T2 On T1.id = T2.id/*SQL Server parse and compile time: CPU time = 46 ms, elapsed time = 66 ms.(1000000 row(s) affected)Table '#TableTwo'. Scan count 3, logical reads 1713, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.Table '#TableOne'. Scan count 3, logical reads 6850, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.SQL Server Execution Times: CPU time = 2922 ms, elapsed time = 14848 ms.*/SelectT1.ColumnOfInterest, T2.ColumnOfInterestFrom(Select id, ColumnOfInterest From #TableOne) T1Left Join (Select id, ColumnOfInterest From #TableTwo) T2 On T1.id = T2.id/*SQL Server parse and compile time: CPU time = 63 ms, elapsed time = 85 ms.(1000000 row(s) affected)Table '#TableTwo'. Scan count 3, logical reads 1713, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.Table '#TableOne'. Scan count 3, logical reads 6850, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.SQL Server Execution Times: CPU time = 2765 ms, elapsed time = 15404 ms.*/
As you can see, the performance is nearly identical. This is to be expected with the execution plans being nearly identical. The lesson here is to review the Execution Plans and test the queries using Statistics. They will help you to learn how to craft good queries.