Adaptive Join : Threshold rows

sakuraime 2,346 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 | Other
0 comments No comments
{count} votes

Accepted answer
  1. AmeliaGu-MSFT 14,006 Reputation points Microsoft External Staff
    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 14,006 Reputation points Microsoft External Staff
    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 121.8K Reputation points MVP Volunteer Moderator
    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.