Hi Friends,
This is my 18th blog on SQL Server Trace Flag 2528 in the series of One Trace Flag a Day. You can go to all blogs under that series by clicking here.
We all know that by default, SQL Server uses parallelism for request execution. The decision of using parallelism depends on various factors like degree of parallelism, cost threshold for Parallelism etc. it’s a regular activity for a DBA to run DBCC CHECKDB command against the databases. This maintenance activity checks the consistency of database or in other words you can say that All is well inside database or not. Generally SQL Server uses parallelism also for the execution of such commands.
Now the question is: can we disable the parallelism for such DBCC command? The answer is: Yes, we can. Microsoft provides a trace flag 2528 to disable the parallelism for DBCC CHECKDB, DBCC CHECKFILEGROUP and DBCC CHECKTABLE. Let me show you this practically:
First open a new query window and run below command
Select @@SPID
And note down the output. In my case it is 52. Now run the below command in that same query window:
DBCC TRACEON(2528,-1) go DBCC CHECKDB(Test) --You can replace this Test with your Testing Database Name go DBCC TRACEOFF(2528,-1)
Now run the below command in new query window:
sp_who2 52 --replace 52 with the value you got from Select @@SPID command from above step go
Here I got a single row as output, means now it is running without parallelism. Keep in mind that if you will run these DBCC commands without parallelism then the execution of these commands will take longer time to complete as compare to parallelism.
PS: Do not use trace flags in production environment without testing it on non production environments and without consulting because everything comes at a cost.
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