JoeCool
JoeCool

Reputation: 4432

How are inner and left and right outer joins implemented in SQL Server?

I'm looking for a high-level, algorithmic understanding so that I can get a Big-O sense of what SQL-Server is doing to perform joins. Feel free to be concise, I'm not looking for the extremely nitty gritty. The thing that prompted me to understand how joins are implemented better is the scenario behind this question that I also just posted. I felt like they were ultimately two separate questions though, which is why I didn't combine them.

Thanks!

Upvotes: 7

Views: 5001

Answers (3)

Joe Stefanelli
Joe Stefanelli

Reputation: 135809

EDIT (2020-03-11): The links in this 9+ year old answer are all invalid today. I would delete the answer, but SO won't let me since it was accepted back when it was actually useful.

Original Answer:

Here's some reading to get you started.

Upvotes: 10

HLGEM
HLGEM

Reputation: 96552

Honestly if you are interested at that level of detail I would suggest you read Microsoft SQL Server 2008 Internals.

And learn to read execution plans. SQL Server has a pretty good optimization engine. It doesn't always do things the way we humans would expect though or even the same way for two queries that appear to us be similar.

Upvotes: 1

Andomar
Andomar

Reputation: 238076

SQL Server can choose from a variety of different joins: the most common ones are merge, loop and hash. See this KB article.

Upvotes: -1

Related Questions