Skip to content

DevOps Guy

The Ramblings of an Azure enthusiast

  • Courses
  • SQL Server
  • Azure
  • Python
  • LogicApps
  • DevOps
  • Linux
  • MongoDB
  • React
  • .NET
  • MySQL
  • Account
  • Toggle search form

Physical Joins

Posted on July 16, 2019 By joe No Comments on Physical Joins

There are three physical join types in SQL Server they are Nested Loops, Hash Match Join and Merge Join.

 

Hash Match Join

Hash Match join works by having two inputs, SQL server during the build phase will take one of these inputs and will build an in memory table.  Hashs are calculated based on the join input key the whole row is stored in a hash bucket.  Once the hash has been built SQL server will  perform the probe stage SQL server calculates the join key hash for each row in the second input to check if it matches the hash table that was created in the first build phase, SQL server will then check to make sure that the join keys actual match it does this becuase encase of a hash match collison.  Hash Match Join uses tempdb to join large datasets, this physical join is also a blocking operator.

Merge Join

The Merge Join is the fastest physical join, it works by iterating over the rows from the two inputs to comapre them, however the two inputs need to be sorted first either by index sorting or SQL server explcitly sorting the data. A Many-to-Many join creates a worktable in tempdb and SQL server will use this to comapre, once it’s gotten past the duplicate Many-to-Many values the worktable is deleted.

Nested Loops

SQL server will iterate over the rows from the inner input using the outer input to compare the values for a match.  Nested Loops join is CPU intensive, to help with performance it’s best to have the inner table pre-sorted.  Nested loops are used when the data is small or SQL server may use a nested loops join incorectly if you have incorrect estimates.

 

 

 

 

Related

CI \ CD and Source Control SQL Server Using Azure Devops – Part 2October 5, 2020In "Azure"

Version Control SQL Server and Azure DevOpsMarch 31, 2020In "Azure"

CI \ CD and Source Control SQL Server Using Azure Devops – Part 1October 5, 2020In "Azure"

SQL Server

Post navigation

Previous Post: At Time Zone
Next Post: Configuring High Availablity SQL Server

Related Posts

Azure devops Logo CI \ CD and Source Control SQL Server Using Azure Devops – Part 2 Azure
Date and Time Parts SQL Server
SQL Server Logo Custom Table Type, Table Valued Parameter and Stored Procedure SQL Server
Azure devops Logo CI \ CD and Source Control SQL Server Using Azure Devops – Part 1 Azure
Create Trigger to prevent bulk update of table SQL Server
SQL Server Logo When to Use Columnstore vs Rowstore: A Guide for SQL Server Administrators SQL Server

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • Azure DevOps Templates and Variables
  • Logic app to Service Bus
  • Publish Azure DevOps Artifact
  • Azure AKS Backup
  • Assign User Assigned Managed Identity to Azure SQL

Recent Comments

    Archives

    • December 2024
    • May 2024
    • April 2024
    • February 2024
    • January 2024
    • November 2023
    • September 2023
    • August 2023
    • July 2023
    • March 2023
    • February 2023
    • January 2023
    • February 2022
    • February 2021
    • December 2020
    • October 2020
    • April 2020
    • March 2020
    • February 2020
    • January 2020
    • October 2019
    • September 2019
    • August 2019
    • July 2019

    Categories

    • .NET
    • Azure
    • DevOps
    • Linux
    • LogicApps
    • MongoDB
    • MySQL
    • Powershell
    • Python
    • React
    • Rust
    • Software
    • SQL Server
    • Terraform
    • Tools

    Meta

    • Register
    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Copyright © 2025 DevOps Guy.

    Powered by PressBook Grid Dark theme