%3CLINGO-SUB%20id%3D%22lingo-sub-1538528%22%20slang%3D%22en-US%22%3EChanging%20default%20MAXDOP%20in%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538528%22%20slang%3D%22en-US%22%3E%3CH2%20id%3D%22toc-hId--1298936014%22%20id%3D%22toc-hId--1298224754%22%20id%3D%22toc-hId--1298224754%22%20id%3D%22toc-hId--1298224754%22%20id%3D%22toc-hId--1298224754%22%3EExecutive%20Summary%3C%2FH2%3E%0A%3CP%3ETo%20improve%20customer%20workload%20performance%20and%20reduce%20unnecessary%20resource%20utilization%2C%20the%20default%20MAXDOP%20setting%20for%20new%20databases%20in%20Azure%20SQL%20Database%20is%20changing%20from%20the%20previous%20default%20of%200%20(unlimited)%20to%208.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1188576819%22%20id%3D%22toc-hId-1189288079%22%20id%3D%22toc-hId-1189288079%22%20id%3D%22toc-hId-1189288079%22%20id%3D%22toc-hId-1189288079%22%3EWhy%20MAXDOP%20matters%3C%2FH2%3E%0A%3CP%3EThe%20%E2%80%9Cmax%20degree%20of%20parallelism%E2%80%9D%20(a.k.a.%20MAXDOP)%20SQL%20Server%20configuration%20option%20controls%20the%20ability%20of%20the%20database%20engine%20to%20use%20parallel%20threads%20during%20query%20processing.%20When%20MAXDOP%20is%20other%20than%201%2C%20the%20database%20engine%20may%20execute%20queries%20using%20multiple%20concurrent%20threads.%20This%20often%20results%20in%20shorter%20query%20duration%20due%20to%20additional%20CPU%20resources%20used%20for%20query%20processing.%20The%20number%20of%20concurrently%20executing%20threads%2C%20and%20the%20resulting%20CPU%20utilization%2C%20depends%20on%20the%20MAXDOP%20value.%20Higher%20values%20generally%20result%20in%20more%20threads%20and%20higher%20resource%20utilization.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20a%20query%20is%20using%20parallelism%2C%20it%20often%20gets%20faster%20as%20MAXDOP%20is%20increased%2C%20though%20after%20some%20point%20additional%20threads%20may%20just%20use%20extra%20CPU%20cycles%20without%20reducing%20query%20duration.%20To%20learn%20more%20about%20query%20parallelism%2C%20see%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fquery-processing-architecture-guide%23DOP%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDegree%20of%20Parallelism%3C%2FA%3E%20section%20in%20the%20Query%20Processing%20Architecture%20Guide.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAzure%20SQL%20uses%20the%20SQL%20Server%20database%20engine%2C%20thus%20MAXDOP%20considerations%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fdatabase-engine%2Fconfigure-windows%2Fconfigure-the-max-degree-of-parallelism-server-configuration-option%23Guidelines%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Erecommendations%3C%2FA%3E%20for%20SQL%20Server%20are%20also%20applicable%20to%20Azure%20SQL.%20This%20includes%20single%20databases%2C%20databases%20in%20elastic%20pools%2C%20and%20managed%20instances.%20For%20all%20of%20these%20deployment%20options%2C%20customers%20can%20control%20MAXDOP%20at%20the%20database%20level%20using%20the%20MAXDOP%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Ft-sql%2Fstatements%2Falter-database-scoped-configuration-transact-sql%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edatabase-scoped%20configuration%3C%2FA%3E.%26nbsp%3B%20For%20managed%20instances%2C%20customers%20can%20also%20set%20the%20server%20'%3CEM%3Emax%20degree%20of%20parallelism'%3C%2FEM%3E%20configuration%20option%2C%20and%20can%20control%20MAXDOP%20at%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Frelational-databases%2Fresource-governor%2Fresource-governor%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EResource%20Governor%3C%2FA%3E%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Ft-sql%2Fstatements%2Fcreate-workload-group-transact-sql%3Fview%3Dazuresqldb-mi-current%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eworkload%20group%3C%2FA%3E%20level.%20For%20all%20Azure%20SQL%20deployment%20options%2C%20MAXDOP%20can%20additionally%20be%20controlled%20at%20the%20individual%20query%20level%20by%20using%20the%20OPTION%20(MAXDOP)%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Ft-sql%2Fqueries%2Fhints-transact-sql-query%3Fview%3Dsql-server-ver15%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Equery%20hint%3C%2FA%3E%2C%20which%20overrides%20MAXDOP%20configurations%20set%20in%20the%20database%20or%20instance%20scope%20(though%20without%20exceeding%20the%20Resource%20Governor%20workload%20group%20cap%2C%20if%20any).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EChanging%20MAXDOP%20can%20have%20major%20impact%20on%20query%20performance%20and%20resource%20utilization%2C%20both%20positive%20and%20negative.%20However%2C%20there%20is%20not%20a%20single%20MAXDOP%20value%20that%20is%20optimal%20for%20all%20workloads.%20The%20recommendations%20for%20setting%20MAXDOP%20are%20nuanced%2C%20and%20depend%20on%20many%20factors.%20Customers%20wishing%20to%20achieve%20optimal%20performance%20for%20their%20workloads%20may%20need%20to%20fine-tune%20MAXDOP%2C%20using%20published%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fdatabase-engine%2Fconfigure-windows%2Fconfigure-the-max-degree-of-parallelism-server-configuration-option%23Guidelines%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Erecommendations%3C%2FA%3E%20as%20the%20starting%20point.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EImportantly%2C%20while%20increasing%20MAXDOP%20often%20reduces%20duration%20for%20long-running%20queries%2C%20%3CEM%3Eexcessive%20parallelism%20can%20cause%20unnecessary%20CPU%20and%20worker%20utilization%3C%2FEM%3E%2C%20and%20make%20the%20overall%20workload%20performance%20worse%20by%20starving%20other%20queries%20of%20these%20resources.%20In%20extreme%20cases%2C%20excessive%20parallelism%20can%20consume%20all%20database%20or%20elastic%20pool%20resources%2C%20causing%20query%20timeouts%2C%20errors%2C%20and%20application%20outages.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHistorically%2C%20the%20default%20MAXDOP%20value%20in%20SQL%20Server%20has%20always%20been%20set%20to%200.%20This%20means%20that%20query%20parallelism%20is%20limited%20only%20by%20the%20hardware%20bounds%20of%20the%20machine%20running%20the%20SQL%20Server%20instance%20(up%20to%20the%20maximum%20MAXDOP%20of%2064).%20For%20backward%20compatibility%20reasons%2C%20this%20remains%20the%20default%20value%20in%20SQL%20Server%2C%20though%20starting%20with%20SQL%20Server%202019%2C%20it%20is%20possible%20to%20change%20the%20instance%20level%20MAXDOP%20during%20initial%20instance%20setup.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Azure%20SQL%20Database%2C%20the%20default%20MAXDOP%20value%20has%20also%20been%20set%20to%200%20(unlimited)%20for%20every%20new%20database%2C%20for%20similar%20reasons.%20However%2C%20over%20time%2C%20and%20especially%20as%20databases%20and%20elastic%20pools%20with%20many%20cores%20became%20widely%20used%2C%20performance%20problems%20due%20to%20excessive%20parallelism%20caused%20by%20MAXDOP%20set%20to%200%20became%20more%20frequent.%20This%20particularly%20impacts%20customers%20who%20are%20not%20familiar%20with%20the%20MAXDOP%20option%2C%20and%20leave%20it%20at%20the%20default%20of%200.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20address%20these%20performance%20problems%2C%20we%20are%20making%20the%20following%20change%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3EFor%20every%20new%20single%20database%20and%20elastic%20pool%20database%2C%20the%20MAXDOP%20database-scoped%20configuration%20will%20be%20set%20to%208%20by%20default.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--618877644%22%20id%3D%22toc-hId--618166384%22%20id%3D%22toc-hId--618166384%22%20id%3D%22toc-hId--618166384%22%20id%3D%22toc-hId--618166384%22%3EFrequently%20Asked%20Questions%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhy%20are%20you%20changing%20default%20MAXDOP%20for%20new%20Azure%20SQL%20databases%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20change%20is%20to%20reduce%20the%20frequency%20and%20severity%20of%20incidents%20caused%20by%20excessive%20query%20parallelism%2C%20and%20to%20improve%20customer%20workload%20performance%20by%20reducing%20unnecessary%20resource%20utilization.%20We%20expect%20that%20this%20change%20will%20benefit%20the%20overwhelming%20majority%20of%20customers%20using%20Azure%20SQL%20Database.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhen%20will%20this%20change%20happen%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWe%20expect%20this%20change%20to%20roll%20out%20worldwide%20in%20August%20of%202020.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWill%20this%20change%20impact%20my%20existing%20Azure%20SQL%20databases%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ENo.%20Existing%20databases%20will%20not%20be%20modified.%20This%20change%20applies%20only%20to%20new%20databases%20created%20after%20this%20change%20is%20rolled%20out.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EDoes%20this%20change%20apply%20to%20Azure%20SQL%20Managed%20Instance%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ENo%2C%20at%20this%20time%20this%20change%20only%20applies%20to%20single%20databases%20and%20databases%20in%20elastic%20pools%20in%20Azure%20SQL%20Database.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EI%20know%20that%20MAXDOP%20setting%20different%20from%208%20is%20optimal%20for%20my%20workload.%20What%20should%20I%20do%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ECustomers%20who%20have%20determined%20that%20a%20specific%20MAXDOP%20setting%20is%20optimal%20for%20their%20workloads%2C%20or%20customers%20who%20prefer%20to%20keep%20MAXDOP%200%20used%20previously%20by%20default%2C%20can%20add%20a%20step%20to%20their%20database%20deployment%20processes%20to%20change%20MAXDOP%20after%20database%20creation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EShould%20I%20change%20MAXDOP%20on%20my%20existing%20Azure%20SQL%20databases%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ECustomers%20with%20existing%20databases%20that%20use%20the%20default%20MAXDOP%200%20should%20consider%20changing%20MAXDOP%20according%20to%20standing%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fdatabase-engine%2Fconfigure-windows%2Fconfigure-the-max-degree-of-parallelism-server-configuration-option%23Guidelines%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Erecommendations%3C%2FA%3E%3CSPAN%3E.%3C%2FSPAN%3E%20This%20may%20improve%20performance%2C%20reduce%20the%20risk%20of%20performance%20and%20availability%20incidents%2C%20and%20in%20some%20cases%20reduce%20costs%20by%20being%20able%20to%20avoid%20unnecessary%20resource%20utilization%2C%20and%20thus%20scale%20down%20to%20a%20lower%20service%20objective.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20recommend%20that%20customers%20avoid%20MAXDOP%200%20even%20if%20it%20does%20not%20appear%20to%20cause%20problems%20currently.%20This%20will%20reduce%20the%20risk%20of%20potential%20future%20problems%20due%20to%20excessive%20parallelism%20if%20a%20database%20is%20scaled%20up%20to%20use%20more%20cores%2C%20or%20if%20future%20hardware%20generations%20in%20Azure%20SQL%20provide%20more%20cores%20for%20the%20same%20database%20service%20objective.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20with%20most%20configuration%20changes%2C%20thorough%20testing%20is%20recommended%20before%20making%20changes%20in%20critical%20environments.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHow%20can%20I%20change%20MAXDOP%20for%20an%20existing%20database%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EMAXDOP%20can%20be%20changed%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Ft-sql%2Fstatements%2Falter-database-scoped-configuration-transact-sql%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EALTER%20DATABASE%20SCOPED%20CONFIGURATION%3C%2FA%3E%20statement%20in%20the%20scope%20of%20a%20database.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20execute%20the%20necessary%20T-SQL%20statement%2C%20customers%20can%20use%20any%20client%20tool%20or%20programming%20language%20that%20can%20connect%20to%20the%20database%20and%20execute%20T-SQL%20commands.%20The%20following%20client%20tools%20are%20commonly%20used%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsql-database%2Fsql-database-connect-query-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EQuery%20editor%3C%2FA%3E%2C%20which%20is%20a%20part%20of%20Azure%20portal.%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Fssms%2Fdownload-sql-server-management-studio-ssms%3Fview%3Dsql-server-ver15%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESQL%20Server%20Management%20Studio%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Fazure-data-studio%2Fdownload-azure-data-studio%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Data%20Studio%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EFor%20example%2C%20to%20change%20MAXDOP%20to%204%2C%20use%20the%20following%20T-SQL%20command%20when%20connected%20to%20the%20target%20database%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3EALTER%20DATABASE%20SCOPED%20CONFIGURATION%20SET%20MAXDOP%20%3D%204%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHow%20do%20I%20know%20if%20a%20change%20to%20MAXDOP%20made%20a%20difference%20for%20my%20workload%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ECustomers%20can%20see%20the%20impact%20of%20a%20change%20in%20MAXDOP%20by%20making%20sure%20that%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Frelational-databases%2Fperformance%2Fmonitoring-performance-by-using-the-query-store%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EQuery%20Store%3C%2FA%3E%20is%20enabled%20for%20a%20representative%20period%20of%20time%20before%20and%20after%20the%20change%20is%20made%2C%20to%20capture%20resource%20utilization%20and%20performance%20statistics%20for%20each%20query.%20For%20more%20details%2C%20see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Frelational-databases%2Fperformance%2Fquery-store-usage-scenarios%23ab-testing%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EA%2FB%20testing%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhat%20are%20the%20symptoms%20of%20excessive%20query%20parallelism%20in%20Azure%20SQL%20Database%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIn%20Azure%20SQL%20Database%2C%20one%20common%20symptom%20of%20excessive%20parallelism%20is%20exceeding%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsql-database%2Fsql-database-resource-limits-database-server%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eresource%20governance%3C%2FA%3E%20limits%20on%20the%20number%20of%20worker%20threads.%20When%20this%20happens%2C%20error%20%3CEM%3E10928%2C%20%E2%80%9CResource%20ID%20%3A%201.%20The%20request%20limit%20for%20the%20database%20is%20N%20and%20has%20been%20reached%E2%80%9D%3C%2FEM%3E%20is%20raised%2C%20where%20%3CEM%3EN%3C%2FEM%3E%20stands%20for%20the%20worker%20thread%20limit%20for%20the%20database%20or%20elastic%20pool%20(note%2C%20however%2C%20that%20there%20are%20other%20possible%20causes%20for%20this%20error).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECXPACKET%20waits%20may%20be%20another%20symptom%20of%20excessive%20parallelism.%20Some%20amount%20of%20CXPACKET%20waits%20is%20normal%20whenever%20query%20parallelism%20is%20used%3B%20however%2C%20if%20CXPACKET%20waits%20dominate%20other%20waits%20types%20while%20CPU%20utilization%20is%20greater%20than%2080-90%25%2C%20it%20likely%20also%20indicates%20excessive%20parallelism.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhy%20did%20you%20choose%208%20as%20the%20new%20default%20MAXDOP%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EOur%20telemetry%20data%20and%20our%20experience%20running%20the%20Azure%20SQL%20Database%20service%20show%20that%20MAXDOP%208%20is%20the%20optimal%20value%20for%20the%20widest%20variety%20of%20customer%20workloads.%20It%20is%20a%20safe%20option%20that%20reduces%20the%20likelihood%20of%20performance%20problems%20due%20to%20excessive%20parallelism%2C%20while%20still%20allowing%20queries%20to%20execute%20faster%20by%20using%20more%20threads.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20the%20same%20time%2C%20workloads%20where%20a%20different%20MAXDOP%20value%20is%20optimal%20do%20exist.%20Customers%20can%20experiment%20with%20different%20MAXDOP%20settings%20to%20determine%20what%20works%20best%20for%20them.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EShouldn%E2%80%99t%20the%20database%20engine%20automatically%20choose%20the%20optimal%20degree%20of%20parallelism%20for%20every%20query%20it%20executes%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EImprovements%20in%20Azure%20SQL%20and%20the%20SQL%20Server%20database%20engine%20are%20made%20continuously.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsql-database%2Fsql-database-automatic-tuning%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAutomatic%20Tuning%3C%2FA%3E%2C%20and%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Frelational-databases%2Fperformance%2Fintelligent-query-processing%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIntelligent%20Query%20Processing%3C%2FA%3E%20family%20of%20features%20are%20two%20examples%20of%20improvements%20in%20query%20processing%20and%20query%20performance%20made%20in%20recent%20years.%20Today%2C%20the%20database%20engine%20already%20reduces%20query%20parallelism%20at%20query%20startup%20time%20in%20response%20to%20a%20shortage%20of%20available%20worker%20threads.%20Query%20processing%20improvements%20in%20future%20releases%20of%20the%20database%20engine%20may%20adjust%20parallelism%20dynamically%20in%20a%20broader%20set%20of%20scenarios.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhy%20are%20you%20changing%20the%20default%20MAXDOP%20regardless%20of%20the%20database%20service%20objective%3F%20Shouldn%E2%80%99t%20this%20only%20apply%20to%20databases%20with%20more%20than%208%20cores%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ELimiting%20MAXDOP%20to%208%20is%20safe%20for%20databases%20with%208%20or%20less%20cores%20(or%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Frelational-databases%2Fthread-and-task-architecture-guide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Escheduler%3C%2FA%3E%20threads).%20In%20this%20case%2C%20parallelism%20will%20be%20limited%20by%20the%20smaller%20number%20of%20available%20cores%2C%20rather%20than%20by%20the%20MAXDOP%20setting.%20Limiting%20MAXDOP%20to%208%20protects%20smaller%20databases%20from%20being%20exposed%20to%20excessive%20parallelism%20if%20scaled%20up%20to%20use%20more%20than%208%20cores%2C%20or%20if%20future%20hardware%20generations%20in%20Azure%20SQL%20Database%20provide%20more%20cores%20for%20the%20same%20database%20service%20objective.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhat%20is%20the%20impact%20of%20this%20change%20on%20index%20rebuild%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EBy%20default%2C%20indexes%20are%20rebuilt%20with%20parallelism%2C%20using%20the%20database-scoped%20MAXDOP%20setting.%20On%20databases%20with%20more%20than%208%20cores%2C%20this%20change%20may%20cause%20index%20rebuilds%20to%20take%20longer%20due%20to%20lower%20degree%20of%20parallelism%20used.%20If%20this%20happens%2C%20you%20can%20increase%20parallelism%20for%20each%20index%20rebuild%20operation%20by%20using%20the%20MAXDOP%20option%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Ft-sql%2Fstatements%2Falter-index-transact-sql%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EALTER%20INDEX%20%E2%80%A6%20REBUILD%3C%2FA%3E%20statement.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHow%20can%20I%20ask%20questions%20or%20provide%20feedback%20on%20this%20change%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ECustomers%20can%20ask%20questions%20or%20provide%20feedback%20via%20comments%20to%20this%20blog%20post%2C%20or%20via%20email%20to%20IntelligentQP%20%5Bat%5D%20microsoft.com.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1538528%22%20slang%3D%22en-US%22%3E%3CP%3ETo%20improve%20customer%20workload%20performance%20and%20reduce%20unnecessary%20resource%20utilization%2C%20the%20default%20MAXDOP%20setting%20for%20new%20databases%20in%20Azure%20SQL%20Database%20is%20changing%20from%20the%20previous%20default%20of%200%20(unlimited)%20to%208.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1538528%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20SQL%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPerformance%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1544890%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20default%20MAXDOP%20in%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1544890%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F296845%22%20target%3D%22_blank%22%3E%40Johannes_Vink%3C%2FA%3E%26nbsp%3BThanks%20for%20the%20comment.%20The%20query%20you%20posted%20will%20work%20in%20SQL%20Server%20and%20in%20Azure%20SQL%20Managed%20Instance%2C%20however%20it%20will%20always%20return%200%20in%20Azure%20SQL%20Database.%20In%20the%20latter%20case%2C%20the%20database-scoped%20configuration%20is%20what%20controls%20MAXDOP%2C%20so%20the%20query%20should%20be%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESELECT%20name%2C%20value%2C%20value_for_secondary%2C%20is_value_default%3CBR%20%2F%3EFROM%20sys.database_scoped_configurations%3CBR%20%2F%3EWHERE%20name%20%3D%20'MAXDOP'%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20will%20investigate%20the%20possibility%20of%20letting%20customers%20control%20the%20cost%20threshold%20for%20parallelism%20in%20Azure%20SQL%20Database.%20However%2C%20our%20preferred%20long-term%20solution%20would%20be%20to%20improve%20the%20optimizer%20so%20that%20parallelism%20is%20used%20optimally%20in%20all%20cases%20without%20requiring%20configuration%20changes%20by%20users.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1543009%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20default%20MAXDOP%20in%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1543009%22%20slang%3D%22en-US%22%3E%3CP%3EAnd%20to%20query%20the%20current%20MAXDOP%20setting%3A%3C%2FP%3E%3CPRE%3E%3CSTRIKE%3ESELECT%20name%2C%20value_in_use%20FROM%20sys.configurations%20WHERE%20description%20LIKE%20'%25parallelism%25'%3B%3CBR%20%2F%3E%3C%2FSTRIKE%3E--%20Not%20good%20on%20PaaS!%3C%2FPRE%3E%3CP%3EHowever...%20that%20raises%20also%20the%20next%20question%3A%20when%20will%20the%20cost%20threshold%20for%20parallelism%20be%20possible%20to%20be%20modified%3F%20Because%20THAT%20will%20impact%20the%20parallelism%20a%20lot.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.brentozar.com%2Farchive%2F2017%2F03%2Fwhy-cost-threshold-for-parallelism-shouldnt-be-set-to-5%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.brentozar.com%2Farchive%2F2017%2F03%2Fwhy-cost-threshold-for-parallelism-shouldnt-be-set-to-5%2F%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

Executive Summary

To improve customer workload performance and reduce unnecessary resource utilization, the default MAXDOP setting for new databases in Azure SQL Database is changing from the previous default of 0 (unlimited) to 8.

 

Why MAXDOP matters

The “max degree of parallelism” (a.k.a. MAXDOP) SQL Server configuration option controls the ability of the database engine to use parallel threads during query processing. When MAXDOP is other than 1, the database engine may execute queries using multiple concurrent threads. This often results in shorter query duration due to additional CPU resources used for query processing. The number of concurrently executing threads, and the resulting CPU utilization, depends on the MAXDOP value. Higher values generally result in more threads and higher resource utilization.

 

If a query is using parallelism, it often gets faster as MAXDOP is increased, though after some point additional threads may just use extra CPU cycles without reducing query duration. To learn more about query parallelism, see the Degree of Parallelism section in the Query Processing Architecture Guide.

 

Azure SQL uses the SQL Server database engine, thus MAXDOP considerations and recommendations for SQL Server are also applicable to Azure SQL. This includes single databases, databases in elastic pools, and managed instances. For all of these deployment options, customers can control MAXDOP at the database level using the MAXDOP database-scoped configuration.  For managed instances, customers can also set the server 'max degree of parallelism' configuration option, and can control MAXDOP at the Resource Governor workload group level. For all Azure SQL deployment options, MAXDOP can additionally be controlled at the individual query level by using the OPTION (MAXDOP) query hint, which overrides MAXDOP configurations set in the database or instance scope (though without exceeding the Resource Governor workload group cap, if any).

 

Changing MAXDOP can have major impact on query performance and resource utilization, both positive and negative. However, there is not a single MAXDOP value that is optimal for all workloads. The recommendations for setting MAXDOP are nuanced, and depend on many factors. Customers wishing to achieve optimal performance for their workloads may need to fine-tune MAXDOP, using published recommendations as the starting point.

 

Importantly, while increasing MAXDOP often reduces duration for long-running queries, excessive parallelism can cause unnecessary CPU and worker utilization, and make the overall workload performance worse by starving other queries of these resources. In extreme cases, excessive parallelism can consume all database or elastic pool resources, causing query timeouts, errors, and application outages.

 

Historically, the default MAXDOP value in SQL Server has always been set to 0. This means that query parallelism is limited only by the hardware bounds of the machine running the SQL Server instance (up to the maximum MAXDOP of 64). For backward compatibility reasons, this remains the default value in SQL Server, though starting with SQL Server 2019, it is possible to change the instance level MAXDOP during initial instance setup.

 

In Azure SQL Database, the default MAXDOP value has also been set to 0 (unlimited) for every new database, for similar reasons. However, over time, and especially as databases and elastic pools with many cores became widely used, performance problems due to excessive parallelism caused by MAXDOP set to 0 became more frequent. This particularly impacts customers who are not familiar with the MAXDOP option, and leave it at the default of 0.

 

To address these performance problems, we are making the following change:

 

For every new single database and elastic pool database, the MAXDOP database-scoped configuration will be set to 8 by default.

 

Frequently Asked Questions

 

Why are you changing default MAXDOP for new Azure SQL databases?

This change is to reduce the frequency and severity of incidents caused by excessive query parallelism, and to improve customer workload performance by reducing unnecessary resource utilization. We expect that this change will benefit the overwhelming majority of customers using Azure SQL Database.

 

When will this change happen?

We expect this change to roll out worldwide in August of 2020.

 

Will this change impact my existing Azure SQL databases?

No. Existing databases will not be modified. This change applies only to new databases created after this change is rolled out.

 

Does this change apply to Azure SQL Managed Instance?

No, at this time this change only applies to single databases and databases in elastic pools in Azure SQL Database.

 

I know that MAXDOP setting different from 8 is optimal for my workload. What should I do?

Customers who have determined that a specific MAXDOP setting is optimal for their workloads, or customers who prefer to keep MAXDOP 0 used previously by default, can add a step to their database deployment processes to change MAXDOP after database creation.

 

Should I change MAXDOP on my existing Azure SQL databases?

Customers with existing databases that use the default MAXDOP 0 should consider changing MAXDOP according to standing recommendations. This may improve performance, reduce the risk of performance and availability incidents, and in some cases reduce costs by being able to avoid unnecessary resource utilization, and thus scale down to a lower service objective.

 

We recommend that customers avoid MAXDOP 0 even if it does not appear to cause problems currently. This will reduce the risk of potential future problems due to excessive parallelism if a database is scaled up to use more cores, or if future hardware generations in Azure SQL provide more cores for the same database service objective.

 

As with most configuration changes, thorough testing is recommended before making changes in critical environments.

 

How can I change MAXDOP for an existing database?

MAXDOP can be changed using the ALTER DATABASE SCOPED CONFIGURATION statement in the scope of a database.

 

To execute the necessary T-SQL statement, customers can use any client tool or programming language that can connect to the database and execute T-SQL commands. The following client tools are commonly used:

  1. Query editor, which is a part of Azure portal.
  2. SQL Server Management Studio.
  3. Azure Data Studio.

For example, to change MAXDOP to 4, use the following T-SQL command when connected to the target database:

 

ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 4;

 

How do I know if a change to MAXDOP made a difference for my workload?

Customers can see the impact of a change in MAXDOP by making sure that Query Store is enabled for a representative period of time before and after the change is made, to capture resource utilization and performance statistics for each query. For more details, see A/B testing.

 

What are the symptoms of excessive query parallelism in Azure SQL Database?

In Azure SQL Database, one common symptom of excessive parallelism is exceeding the resource governance limits on the number of worker threads. When this happens, error 10928, “Resource ID : 1. The request limit for the database is N and has been reached” is raised, where N stands for the worker thread limit for the database or elastic pool (note, however, that there are other possible causes for this error).

 

CXPACKET waits may be another symptom of excessive parallelism. Some amount of CXPACKET waits is normal whenever query parallelism is used; however, if CXPACKET waits dominate other waits types while CPU utilization is greater than 80-90%, it likely also indicates excessive parallelism.

 

Why did you choose 8 as the new default MAXDOP?

Our telemetry data and our experience running the Azure SQL Database service show that MAXDOP 8 is the optimal value for the widest variety of customer workloads. It is a safe option that reduces the likelihood of performance problems due to excessive parallelism, while still allowing queries to execute faster by using more threads.

 

At the same time, workloads where a different MAXDOP value is optimal do exist. Customers can experiment with different MAXDOP settings to determine what works best for them.

 

Shouldn’t the database engine automatically choose the optimal degree of parallelism for every query it executes?

Improvements in Azure SQL and the SQL Server database engine are made continuously. Automatic Tuning, and the Intelligent Query Processing family of features are two examples of improvements in query processing and query performance made in recent years. Today, the database engine already reduces query parallelism at query startup time in response to a shortage of available worker threads. Query processing improvements in future releases of the database engine may adjust parallelism dynamically in a broader set of scenarios.

 

Why are you changing the default MAXDOP regardless of the database service objective? Shouldn’t this only apply to databases with more than 8 cores?

Limiting MAXDOP to 8 is safe for databases with 8 or less cores (or scheduler threads). In this case, parallelism will be limited by the smaller number of available cores, rather than by the MAXDOP setting. Limiting MAXDOP to 8 protects smaller databases from being exposed to excessive parallelism if scaled up to use more than 8 cores, or if future hardware generations in Azure SQL Database provide more cores for the same database service objective.

 

What is the impact of this change on index rebuild?

By default, indexes are rebuilt with parallelism, using the database-scoped MAXDOP setting. On databases with more than 8 cores, this change may cause index rebuilds to take longer due to lower degree of parallelism used. If this happens, you can increase parallelism for each index rebuild operation by using the MAXDOP option in the ALTER INDEX … REBUILD statement.

 

How can I ask questions or provide feedback on this change?

Customers can ask questions or provide feedback via comments to this blog post, or via email to IntelligentQP [at] microsoft.com.

 

2 Comments
Senior Member

And to query the current MAXDOP setting:

SELECT name, value_in_use FROM sys.configurations WHERE description LIKE '%parallelism%';
-- Not good on PaaS!

However... that raises also the next question: when will the cost threshold for parallelism be possible to be modified? Because THAT will impact the parallelism a lot.

 

https://www.brentozar.com/archive/2017/03/why-cost-threshold-for-parallelism-shouldnt-be-set-to-5/

Microsoft

@Johannes_Vink Thanks for the comment. The query you posted will work in SQL Server and in Azure SQL Managed Instance, however it will always return 0 in Azure SQL Database. In the latter case, the database-scoped configuration is what controls MAXDOP, so the query should be:

 

SELECT name, value, value_for_secondary, is_value_default
FROM sys.database_scoped_configurations
WHERE name = 'MAXDOP';

 

We will investigate the possibility of letting customers control the cost threshold for parallelism in Azure SQL Database. However, our preferred long-term solution would be to improve the optimizer so that parallelism is used optimally in all cases without requiring configuration changes by users.