affinity mask
Bitmask of the CPUs this instance's schedulers may use; 0 lets Windows place the threads.
- デフォルト
0 (Windows decides)- Range
- 0, or a bitmask over the instance's CPUs
- Restart needed
- いいえ
- Default checked on
- SQL Server 2025
何ができるか
Each set bit names a CPU for SQL Server and each clear bit takes it away: on an 8-CPU system, 38 (0x26) is processors 1, 2 and 5. Affinity support for 33 to 64 processors needs a 64-bit OS, and above 64 CPUs the bitmask route gives out; ALTER SERVER CONFIGURATION SET PROCESS AFFINITY is the clearer tool anyway. On SQL Server Express the change takes effect only after a restart.
デフォルト値
0 (Windows decides). 0 (SQL Server 2025). A nonzero value turns thread placement over to SQL Server.
Check the current value
SELECT name, value, value_in_use, minimum, maximum, is_dynamic, is_advanced FROM sys.configurations WHERE name = 'affinity mask'; -- EXEC sp_configure 'affinity mask'; also works, but only while show advanced options is 1; -- otherwise it fails with Msg 15123 because this is an advanced option.
Change it
EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'affinity mask', 38; RECONFIGURE;
No restart: it takes effect when RECONFIGURE runs (sys.configurations.is_dynamic = 1). It is an advanced option, so show advanced options must be on to change it.
When to change it
Deliberate core pinning only, such as keeping a co-located engine on its own cores or shrinking a licensed footprint. For workload isolation, Resource Governor fits better, and ALTER SERVER CONFIGURATION reads clearer than a bitmask.
What can go wrong
A miscounted bitmask shrinks the scheduler pool silently: CPUs you meant to include end up excluded, worker threads crowd onto the rest, and the symptom is generic THREADPOOL pressure with no error naming the cause. A CPU set in both this mask and the affinity I/O mask is a conflict the engine does not allow, so compute the bits once and keep them in one place.
Questions about affinity mask
What is the default value of affinity mask in SQL Server?
0 (Windows decides). 0 (SQL Server 2025). A nonzero value turns thread placement over to SQL Server.
Does changing affinity mask require a restart?
No. No restart: it takes effect when RECONFIGURE runs (sys.configurations.is_dynamic = 1). It is an advanced option, so show advanced options must be on to change it.
When should I change affinity mask?
Deliberate core pinning only, such as keeping a co-located engine on its own cores or shrinking a licensed footprint. For workload isolation, Resource Governor fits better, and ALTER SERVER CONFIGURATION reads clearer than a bitmask.
Back to all SQL Server settings, or check the SQL Server manual for every option.
Check affinity mask on your own server
SQLly runs the query above against SQL Server and the other engines in this reference, from one desktop app on macOS, Windows and Linux.
このページのテキストとデータ: CC BY 4.0、出典は SQLly (sqlly.app) と明記してください。 コードと SQL スニペット: MIT. ライセンスの詳細