Posts

Different between LOOP JOIN, HASH JOIN and MERGE JOIN in SQL Server

Image
LOOP JOIN As its name, it use Loop Algorithm to perform join operation. For a example:      SELECT *           FROM      Sales.SalesOrderHeader H      INNER LOOP JOIN Sales.SalesOrderDetail D ON H.SalesOrderID = D.SalesOrderID Step 1: Loop each record in table  [ SalesOrderHeader ] . Step 2: Loop each record in table  [ SalesOrderDetail ] . If table  [ SalesOrderDetail]  has an index on column  [ SalesOrderID ] , it will loop on index instead of loop on table. Step 3: If match – return Data. HASH JOIN use Hash Algorithm to perform join operation. For a example:          SELECT *      FROM      Sales.SalesOrderHeader H      INNER HASH JOIN Sales.SalesOrderDetail D ON H.SalesOrderID = D.SalesOrderID MERGE JOIN   like LOOP JOIN but it will be sort 2 table [Orde...