main logo
Subject: RE: [NF] INNER JOINS vs LEFT JOINs -- performance-wise
Author: "Cindy Winegarden"
Posted: 2004/06/30 12:49:27
 
View Entire Thread
New Search


Hi Michael,

A left join gets everything on the left side (subject to the Where clause)
and whatever is available on the right side or else nulls. An inner join
gets only rows that match on both sides, subject to the Where clause.

With a left join, a Where clause that restricts the right side will return
nulls even though there are matching rows as far as the condition in the
Join clause is concerned.

Can you demonstrate a Where clause that will give the same results with both
queries assuming that there are some records on the left side that do not
have matching records on the right side but qualify under the Where clause?


Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden .at. mvps DO.T org


-----Original Message-----
From: profoxtech-bounces@leafe.com [mailto:profoxtech-bounces .at. leafe DO.T com] On
Behalf Of MB Software Solutions
Sent: Tuesday, June 29, 2004 4:21 PM
To: profoxtech@leafe.com
Subject: [NF] INNER JOINS vs LEFT JOINs -- performance-wise

SELECT LS.*, RS.FIELD1, RS.FIELD2 ;
from leftside LS ;
inner join rightside RS ;
on ls.key == rs.key

SELECT LS.*, RS.FIELD1, RS.FIELD2 ;
from leftside LS ;
left join rightside RS ;
on ls.key == rs.key

Assuming that there's a WHERE clause that makes you get all leftside records

anyway--none will be excluded--would one JOIN perform better than the other?
I'm
just wondering if there's a performance advantage for one over the other and

thought some SQL guru out there might know...

--Michael

Michael J. Babcock, MCP
MB Software Solutions, LLC
http://mbsoftwaresolutions.com
"Helping you work smarter, not harder, with custom solutions!"






[excessive quoting removed by server]


 
©2004 Cindy Winegarden
<-- Prior Message New Search Next Message -->