Author | Claudio Silva (@claudioessilva) |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Set-DbaMaxDop on GitHub.
Want to see the Bill Of Health for this command? Check out Set-DbaMaxDop.
Sets SQL Server maximum degree of parallelism (Max DOP), then displays information relating to SQL Server Max DOP configuration settings. Works on SQL Server 2005 and higher.
Uses the Test-DbaMaxDop command to get the recommended value if -MaxDop parameter is not specified.
These are just general recommendations for SQL Server and are a good starting point for setting the "max degree of parallelism" option.
You can set MaxDop database scoped configurations if the server is version 2016 or higher
Set-DbaMaxDop
[[-SqlInstance] <DbaInstanceParameter[]>]
[[-SqlCredential] <PSCredential>]
[[-Database] <Object[]>]
[[-ExcludeDatabase] <Object[]>]
[[-MaxDop] <Int32>]
[[-InputObject] <PSObject>]
[-AllDatabases]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Set-DbaMaxDop -SqlInstance sql2008, sql2012
Sets Max DOP to the recommended value for servers sql2008 and sql2012.
PS C:\> Set-DbaMaxDop -SqlInstance sql2014 -MaxDop 4
Sets Max DOP to 4 for server sql2014.
PS C:\> Test-DbaMaxDop -SqlInstance sql2008 | Set-DbaMaxDop
Gets the recommended Max DOP from Test-DbaMaxDop and applies it to to sql2008.
PS C:\> Set-DbaMaxDop -SqlInstance sql2016 -Database db1
Set recommended Max DOP for database db1 on server sql2016.
PS C:\> Set-DbaMaxDop -SqlInstance sql2016 -AllDatabases
Set recommended Max DOP for all databases on server sql2016.
The target SQL Server instance or instances. Defaults to localhost.
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies one or more databases to process. Options for this list are auto-populated from the server. If unspecified, all databases will be processed.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies one or more databases to exclude from processing. Options for this list are auto-populated from the server
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies the Max DOP value to set.
Alias | |
Required | False |
Pipeline | false |
Default Value | -1 |
If Test-SqlMaxDop has been executed prior to this function, the results may be passed in via this parameter.
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
If this switch is enabled, Max DOP will be set on all databases. This switch is only useful on SQL Server 2016 and higher.
Alias | All |
Required | False |
Pipeline | false |
Default Value | False |
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts you for confirmation before running the cmdlet.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |