SQL Server force multi-threading
Is th开发者_如何学JAVAere a way to force a block of T-SQL code to run multi-threaded?
If not, is it possible to avoid running a code block if it would run single-threaded?
No.
The maximum degree of parallelism can be specified but not the minimum. If a query has a parallel plan the decision about the number of processors to use will be made at each execution time dependant upon current server load.
You could maybe increase the probability of this happening in SQL Server 2008 by using resource govenor and putting the query in a high priority group.
As of sql-server-2008-r2 and later it is possible to force multi-threading execution.
the following code will force multi-threaded:
OPTION ( RECOMPILE, QUERYTRACEON 8649 )
and this will force single threading
OPTION (MAXDOP 1)
You can read more on Paul White's blog or just Google the "QUERYTRACEON 8649"
精彩评论