Hey DBA guys! Ever wondered what goes behind when SQL Server chooses a parallel query plan or otherwise? Here's a slideshow explaining that! Happy reading!
Got some feedback? Mail me at love@withsqlserver.com ! Enjoy!
2. How does SQL Server choose a
Parallel Query Plan
to run you query?
iKosmik
3. … Based on how many
cores
your machine has
More cores is a reason to celebrate! This means there is greater chance that
SQL Server will consider the Parallel Query Plan to execute your query!
iKosmik
4. … Are there enough
number of threads
for the parallel run?
That’s self-explanatory. SQL Server looks at the current load on the
database and if it can allocate enough number of threads to make this
parallelism happen.
iKosmik
5. … What
query processing
are you doing in there?
SQL Server is real smart here! It looks at what kind of processing /
computation are you really doing in your query. If it’s a CPU hungry query,
say, something like creating/rebuilding an india, or maybe sorting, then it
decides to run it in parallel.
iKosmik
6. … are there
enough rows for processing?
If there are “not” enough rows to be processed, then SQL Server may drop
the parallelism idea.
iKosmik
7. … Is the
distribution stats up-to-date?
SQL Server looks for an up-to-date distribution statistics in order to consider
running a query with a parallel plan.
iKosmik
8. when does SQL Server choose a
Parallel Query Plan
to run you query?
iKosmik
9. … Depends on the
Cost Threshold for Parallelism
setting
So SQL Server compares the cost of running the query using its Serial Query Plan
with the Cost Threshold for Parallelism value set in your database.
If
Cost of Serial Plan > Cost Threshold for Parallelism
there is a great chance that SQL Server will run your query in using the highest
degree of parallelism possible!
iKosmik