Adaptive Join : Threshold rows

sakuraime 2,316 Reputation points
2021-10-04T06:35:56.82+00:00

Just interesting how to determine the threshold rows of the adaptive join which switch between hash or nested loop ?

137269-image.png

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,607 questions
0 comments No comments
{count} votes

Accepted answer
  1. AmeliaGu-MSFT 13,961 Reputation points Microsoft Vendor
    2021-10-06T07:18:26.077+00:00

    Hi sakuraime,
    Please also check this doc:

    138072-image.png

    Best Regards,
    Amelia


2 additional answers

Sort by: Most helpful
  1. AmeliaGu-MSFT 13,961 Reputation points Microsoft Vendor
    2021-10-05T02:41:23.33+00:00

    Hi sakuraime,

    If the Adaptive Threshold Rows is more than an actual number of rows, SQL Server Engine has preferred nested loop join. If the Adaptive Threshold Rows is less than an actual number of rows, SQL Server Engine has preferred Hash Match join.
    Please refer to this article.

    Best Regards,
    Amelia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Erland Sommarskog 100.8K Reputation points MVP
    2021-10-05T21:17:42.373+00:00

    I mean how this number comes out ?

    >

    half of the actual rows or what?

    I have not checked, but I can't but see that this is a number which is determined at compile time. That is, the optimizer estimates that if the actual number of rows coming into the Adaptive Join operator is lower than the threshold, the nested loops will be the cheapest join method, and but the hash is estimated to be better if the number is above the threshold.