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
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