Execution Flow
Microsoft recommendation: MAXDOP = min(8, logical CPU count). The default cost threshold of 5 is generally too low for modern hardware; 50 is the widely-accepted starting point. Use Test-sqmMaxDop to check current values without changing them.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | Target SQL instance. Default: $env:COMPUTERNAME. |
| -SqlCredential | PSCredential | Optional | SQL authentication credential. |
| -MaxDop | Int | Optional | Explicit MAXDOP value. Default: min(8, logical CPUs). |
| -CostThreshold | Int | Optional | Cost threshold for parallelism. Default: 50. Ignored with -SkipCostThreshold. |
| -SkipCostThreshold | Switch | Optional | Only sets MAXDOP, leaves the cost threshold unchanged. |
| -EnableException | Switch | Optional | Throws terminating errors instead of returning a failed result. |
| -WhatIf / -Confirm | Switch | Optional | Standard ShouldProcess support. |
Return Value
Returns a PSCustomObject with: SqlInstance, PreviousMaxDop, NewMaxDop, LogicalCPUs, PreviousCostThreshold, NewCostThreshold, Status, Message.
Examples
Example 1 — Apply recommended MAXDOP and cost threshold
Set-sqmMaxDop -SqlInstance "SQL01"
Example 2 — Explicit MAXDOP, skip cost threshold
Set-sqmMaxDop -SqlInstance "SQL01" -MaxDop 4 -SkipCostThreshold
Example 3 — Preview change
Set-sqmMaxDop -SqlInstance "SQL01" -WhatIf