From the course: SQL Server Performance for Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Nested loop vs. hash join

Nested loop vs. hash join - SQL Server Tutorial

From the course: SQL Server Performance for Developers

Start my 1-month free trial

Nested loop vs. hash join

- [Instructor] Next we're going to talk about nested loop versus hash joins. These are two different types of joins that are options in SQL Server. And when we say they're options, they're options to the query optimizer. You can influence the behavior which you'll see in the demo. However, typically this isn't something you're going to do and you're going to let the optimizer make the decision for you and the optimizer is going to make that decision based on the number of rows and number of columns and a number of other factors that it's estimated into its costing model to join that data together. In particular, we're going to talk about hash joins and nested loops, but SQL Server also uses merge joins in addition to hash and nested loop joins. What hash joins are is a table that gets created in memory to match values together and bring them together for your join operation. Hash joins are very efficient on a large set of data. They're less efficient on a very small set of data…

Contents