SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Optimizer Join Methods


Optimizer Join Methods

Author
Message
Randy_Dyess
Randy_Dyess
SSC-Enthusiastic
SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)

Group: General Forum Members
Points: 186 Visits: 1
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/RDyess/optimizerjoinmethods.asp



Tatsu
Tatsu
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2498 Visits: 307

I really like these types of articles because it is interesting information that I wouldn't normally go looking for, though I probably should. I might be able to get this information from BOL but has anyone ever sat down and just read BOL? Not very fun.

Is there any chance of a sequel that demonstrates how one might modify a query to get different results? I know most of it relates to indexing but if there is any way to give the SQL Server engine some subtle clues as to how to perform the join rather than using query hints, that would be pretty cool.



Bryant E. Byrd, BSSE MCDBA MCAD
Business Intelligence Administrator
MSBI Administration Blog
Randy_Dyess
Randy_Dyess
SSC-Enthusiastic
SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)SSC-Enthusiastic (186 reputation)

Group: General Forum Members
Points: 186 Visits: 1

Bryant,

You are right about the indexes being one of the keys. Another is size of the data inputs. It is hard (nearly impossible) to "push" the optimizer to choose one join over the other without adding/removing indexes or dramatically growing/decreasing the size of the result set.

I usually scan for the join type and if it is not the one I think the optimizer should be using (my best guess) then I try to figure out why. Most of the time hash joins show up when I think merge joins should have been used. I can usually trace these back to lack of indexes or out-dated statistics. Every now and then I find a nested loop join when I think the optimizer should be doing a merge. (My guess is usually based on result set size.) I sometimes try to push the optimizer into a merge, but in the end this does not really buy me much in optimization.

Randy





John Kanagaraj
John Kanagaraj
SSC-Enthusiastic
SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)

Group: General Forum Members
Points: 152 Visits: 12

Randy,

This is a great article on a difficult subject, and you have explained it well. IMHO however, it seems that a discussion on table/column/index statistics and the influence they play on the optimizer (or even a mention) was missing.... I come from the Oracle world and the optimizer is a favorite subject (see http://www.ioug.org/select/articles/05q2/index.cfm for an article I wrote).

Regards,

John Kanagaraj


Mike Seattle
Mike Seattle
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 51
I have a question... Is it possible to tell SQL Server to use a particular join method? Or do you always rely on the Query Optimizer to choose the most appropriate method?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search