Click to See Complete Forum and Search --> : Joining tables using an inner join


vikrampschauhan
January 29th, 2005, 11:56 PM
Say I join two tables using a inner join:

select*from titles join titleauthor on titles.title_id=titleauthor.title_id

When I viewed the execution plan, it showed me that for each row of the outer table, the inner table is scanned and matching rows are output -

StmtText
------------------------------------------------------------------------------------------------------
|--Nested Loops(Inner Join, OUTER REFERENCES:([titleauthor].[title_id]))
|--Clustered Index Scan(OBJECT:([pubs].[dbo].[titleauthor].[UPKCL_taind]))
|--Clustered Index Seek(OBJECT:([pubs].[dbo].[titles].[UPKCL_titleidind]), SEEK:([titles].[title_id]=[titleauthor].[title_id]) ORDERED FORWARD)

(3 row(s) affected)




I was always of the opinion that even for a inner join - first a cross join is performed between the two tables and then, matching rows are selected.

I guess I was wrong, and this is the way things actually happen?


Thanks
Vikram

Krzemo
January 31st, 2005, 04:37 AM
As I told U before - Query Optimiser usualy makes some changes in execution plan:rolleyes: . It was specialy designed to do that :D .
Best regards,
Krzemo.