HI Friends,

We know about parallelism in SQL Server i.e. SQL Server uses multiple threads for the processing of a request to make it faster.  Two main important settings for the decision of going with parallelism are:

MAXDOP: Maximum degree of parallelism, This value represents, how many threads can be used for parallel processing.

The Cost threshold for parallelism: if any estimated query plan cost crossed this value, then the SQL Server optimizer will try to make that plan parallel.

Now come back to our topic, Reserved threads and Used threads in parallelism. Let’s say I have submitted a query to the SQL Server and estimated cost of this query has been crossed the value of cost threshold for parallelism. SQL Server has been decided to execute that query using parallelism. In my test system, MAXDOP is set to default. That means SQL Server can use all the processors for parallel operations, assign to it i.e. 4. I have set the value 0 for cost threshold for parallelism just to use the parallelism for every query (keep in mind this is just for demo). By default, SQL Server uses threads to perform its task and these tasks run on schedulers.

Like many other resources, SQL Server also reserved the number of threads. Let me show you the execution plan of below query on Adventure Works 2014 Database :

Plan1

Now you can just right click on the select node and go to the properties:

Properties1

In the above Properties, you can see that SQL Server uses Degree of Parallelism to 2. Also count the branch for this execution which is 1. Number of reserved threads and used threads are 2.

Keep in mind that number of reserved or used threads are not always equal to the value of MAXDOP for the query. Let me show you:

Plan2

Now you can just right click on the select node and go to the properties:

Properties2

In the above Properties, you can see that SQL Server uses Degree of Parallelism 4. Here branch count for this execution is 2. Number of reserved threads and used threads are 8.

HAPPY LEARNING!

Regards:

Prince Kumar Rastogi

Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook

Follow Prince Rastogi on Twitter | Follow Prince Rastogi on FaceBook