sql server trace flag 2528

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

 

traceflag_2528_1

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

Data Platform Virtual Summit 2020

Subscribe to SQLServerGeeks YouTube channel. If you want more learning content in your inbox, subscribe to SQLServerGeeks Bulletin.

SQLServerGeeks YouTube | SQLServerGeeks Bulletin | SQLServerGeeks Twitter

Avatar

About Prince Rastogi

Prince Rastogi is working as Database Administrator at Elephant Insurance, Richmond. He is having more than 8 years of experience and worked in ERP Domain, Wealth Management Domain. Currently he is working in Insurance domain. In the starting of his career he was working on SQL Server, Internet Information Server and Visual Source Safe. He is post graduate in Computer Science. Prince is ITIL certified professional. Prince likes to explore technical things for Database World and Writing Blogs. He is Technical Editor and Blogger at SQLServerGeeks.com. He is a regular speaker at DataPlatformDay events in Delhi NCR. He has also presented some in depth sessions about SQL Server in SQL Server Conferences in Bangalore.

View all posts by Prince Rastogi →

Leave a Reply

Your email address will not be published. Required fields are marked *