What CPU and OS Settings Are Actually Doing to SQL Server
OS and Hardware Info tells you what hardware exists. These two scripts go one level deeper: how SQL Server is actually scheduling work across that hardware, and whether a handful of OS-level settings invisible from Task Manager, Lock Pages in Memory, NUMA alignment, Instant File Initialization, scheduler affinity, are quietly helping or hurting.
Get-SqlServerCpuTopologyAndSchedulerDetails gives the raw topology: sockets, cores, NUMA nodes, schedulers, MAXDOP and cost threshold in one row. Get-OsConfigurationChecks takes that same topology and grades it, flagging offline schedulers, LPIM status, and IFI in one pass, so a misconfiguration reads as a WARN, not a number you have to interpret yourself.
Why CPU Topology and OS Configuration Matter
- A CPU affinity mask that leaves schedulers offline silently caps SQL Server’s usable CPU, invisible unless you specifically check for it
- Lock Pages in Memory (LPIM) not being active means Windows can page out SQL Server’s buffer pool under memory pressure, a real and avoidable performance cliff on a memory-constrained box
- Instant File Initialization (IFI) not being enabled makes every data file autogrowth event stall while Windows zeroes pages, turning routine growth into a visible, avoidable pause
- NUMA topology affects how SQL Server allocates and schedules memory and worker threads; a single NUMA node with many CPUs is a candidate for soft-NUMA, multiple NUMA nodes need to be understood before tuning MAXDOP or CTFP
On this page
When to Run These Scripts
- First review of any unfamiliar or inherited server, alongside the rest of the Server Inventory cluster
- Before any MAXDOP, cost threshold for parallelism, or affinity mask change, to confirm the topology you’re tuning against
- When investigating unexplained autogrowth stalls (check IFI) or memory pressure that doesn’t match configured
max server memory(check LPIM) - Periodically on any production server, these settings rarely change on their own, but a rebuild, VM resize, or OS patch can silently reset them
The Scripts
Get-SqlServerCpuTopologyAndSchedulerDetails: Raw Topology
- Tested on: SQL Server 2025 (CU8), Windows lab instance
- Last verified: 2026-10-29 (both scripts on this page run, saved outputs from real runs)
- Permissions: VIEW SERVER STATE
- Safety: read-only, impact low
/*
Script Name : Get-SqlServerCpuTopologyAndSchedulerDetails
Category : configuration-and-environment
Purpose : CPU topology, NUMA layout, scheduler summary, and parallelism configuration in one row.
Author : Peter Whyte (https://sqldba.blog/dba-scripts-get-cpu-topology-and-os-config/)
Requires : VIEW SERVER STATE
Notes : Physical cores = socket_count x cores_per_socket (SQL Server 2016 SP2+).
hyperthread_ratio is logical processors per socket, not a core count.
*/
-- SAFE:ReadOnly
-- IMPACT:Low
SET NOCOUNT ON;
SELECT
SERVERPROPERTY('MachineName') AS machine_name,
SERVERPROPERTY('Edition') AS sql_edition,
SERVERPROPERTY('ProductVersion') AS sql_version,
osi.cpu_count AS logical_cpu_count,
osi.hyperthread_ratio,
osi.socket_count AS sockets,
osi.cores_per_socket,
osi.socket_count * osi.cores_per_socket AS physical_core_count,
osi.numa_node_count,
osi.scheduler_count AS online_schedulers,
osi.scheduler_total_count AS total_schedulers,
osi.max_workers_count,
osi.virtual_machine_type_desc,
osi.sqlserver_start_time,
(SELECT value_in_use FROM sys.configurations WHERE name = 'max degree of parallelism') AS maxdop,
(SELECT value_in_use FROM sys.configurations WHERE name = 'cost threshold for parallelism') AS cost_threshold,
(SELECT value_in_use FROM sys.configurations WHERE name = 'affinity mask') AS affinity_mask
FROM sys.dm_os_sys_info AS osi;
/*
-- Per-NUMA node detail (run separately in SSMS):
SELECT node_id, node_state_desc, memory_node_id, online_scheduler_count,
active_worker_count, avg_load_balance
FROM sys.dm_os_nodes
WHERE node_state_desc <> 'ONLINE DAC'
ORDER BY node_id;
-- Per-scheduler detail (run separately in SSMS):
SELECT scheduler_id, parent_node_id, status, is_idle,
current_tasks_count, runnable_tasks_count, work_queue_count, load_factor
FROM sys.dm_os_schedulers
WHERE scheduler_id < 255 AND status = 'VISIBLE ONLINE'
ORDER BY parent_node_id, scheduler_id;
*/
Get-OsConfigurationChecks: Graded Health Check
/*
Script Name : Get-OsConfigurationChecks
Category : monitoring
Purpose : DMV-accessible OS and hardware configuration checks: Lock Pages in Memory,
NUMA topology, scheduler affinity, and Instant File Initialization (SQL 2019+).
Surfaces common misconfigurations invisible from inside SQL Server.
Pair with Test-OsConfiguration.ps1 for power plan and page file checks.
Author : Peter Whyte (https://sqldba.blog/dba-scripts-get-cpu-topology-and-os-config/)
Requires : VIEW SERVER STATE
Notes : Physical cores = socket_count x cores_per_socket (SQL Server 2016 SP2+).
*/
-- SAFE:ReadOnly
-- IMPACT:Low
SET NOCOUNT ON;
WITH numa_summary AS (
SELECT
COUNT(DISTINCT node_id) AS numa_node_count,
SUM(online_scheduler_count) AS online_schedulers
FROM sys.dm_os_nodes
WHERE node_state_desc NOT LIKE '%DAC%'
),
offline_schedulers AS (
SELECT COUNT(*) AS offline_count
FROM sys.dm_os_schedulers
WHERE status = 'VISIBLE OFFLINE'
AND scheduler_id < 255
),
cfg AS (
SELECT
MAX(CASE WHEN name = 'max server memory (MB)' THEN CAST(value_in_use AS BIGINT) END) AS max_server_memory_mb,
MAX(CASE WHEN name = 'min server memory (MB)' THEN CAST(value_in_use AS BIGINT) END) AS min_server_memory_mb
FROM sys.configurations
)
SELECT
osi.cpu_count AS logical_cpu_count,
osi.socket_count AS sockets,
osi.cores_per_socket,
osi.socket_count * osi.cores_per_socket AS physical_core_count,
n.numa_node_count,
n.online_schedulers AS sql_online_schedulers,
os_off.offline_count AS sql_offline_schedulers,
CASE
WHEN os_off.offline_count > 0
THEN 'WARN - ' + CAST(os_off.offline_count AS VARCHAR) +
' scheduler(s) offline; CPU affinity mask may be limiting SQL Server'
ELSE 'OK'
END AS scheduler_status,
CASE
WHEN n.numa_node_count > osi.socket_count
THEN 'INFO - soft-NUMA active (' + CAST(n.numa_node_count AS VARCHAR) +
' SQL NUMA nodes vs ' + CAST(osi.socket_count AS VARCHAR) + ' sockets)'
WHEN n.numa_node_count = 1 AND osi.cpu_count > 8
THEN 'INFO - single NUMA node with ' + CAST(osi.cpu_count AS VARCHAR) +
' CPUs; consider soft-NUMA for NUMA-aware memory allocation'
ELSE 'OK'
END AS numa_status,
osi.sql_memory_model_desc AS memory_model,
CASE osi.sql_memory_model_desc
WHEN 'CONVENTIONAL'
THEN 'WARN - LPIM not active; OS can page out SQL buffer pool under memory pressure'
WHEN 'LOCK_PAGES' THEN 'OK - Lock Pages in Memory is active'
WHEN 'LARGE_PAGES' THEN 'OK - Large Pages active (implies LPIM)'
ELSE 'UNKNOWN'
END AS lpim_status,
CAST(osi.physical_memory_kb / 1024.0 / 1024 AS DECIMAL(10,2)) AS physical_memory_gb,
c.max_server_memory_mb,
c.min_server_memory_mb,
CAST(osi.physical_memory_kb / 1024 -
CASE WHEN osi.physical_memory_kb / 1024 > 16384 THEN 4096
WHEN osi.physical_memory_kb / 1024 > 4096 THEN 2048
ELSE 1024 END AS BIGINT) AS recommended_max_mem_mb,
CASE
WHEN CAST(SERVERPROPERTY('ProductMajorVersion') AS INT) >= 15
THEN ISNULL(
(SELECT TOP 1 CAST(instant_file_initialization_enabled AS NVARCHAR(5))
FROM sys.dm_server_services
WHERE servicename LIKE 'SQL Server (%'
AND filename NOT LIKE '%sqlagent%'
AND filename NOT LIKE '%OLAP%'),
'N/A')
ELSE 'N/A (pre-2019)'
END AS ifi_enabled,
CASE
WHEN CAST(SERVERPROPERTY('ProductMajorVersion') AS INT) >= 15
AND EXISTS (
SELECT 1 FROM sys.dm_server_services
WHERE servicename LIKE 'SQL Server (%'
AND filename NOT LIKE '%sqlagent%'
AND instant_file_initialization_enabled = 'Y')
THEN 'OK - IFI active; autogrowth and data file creation do not zero pages'
WHEN CAST(SERVERPROPERTY('ProductMajorVersion') AS INT) >= 15
THEN 'WARN - IFI not enabled; autogrowth events stall while OS zeroes pages'
ELSE 'INFO - IFI cannot be confirmed via SQL on pre-2019 instances; verify SE_MANAGE_VOLUME_NAME Windows privilege'
END AS ifi_status,
osi.sqlserver_start_time AS sql_start_time,
DATEDIFF(DAY, osi.sqlserver_start_time, GETDATE()) AS uptime_days
FROM sys.dm_os_sys_info AS osi
CROSS JOIN numa_summary AS n
CROSS JOIN offline_schedulers AS os_off
CROSS JOIN cfg AS c;
How To Run From The Repo
Clone DBA Tools, initialize and run whichever script answers your question:
# Clone dba-tools repo:
git clone https://github.com/peterwhyte-lgtm/dba-tools
# Initialize environment:
cd dba-tools
.\Initialize-Environment.ps1
# Raw CPU topology, NUMA layout, and parallelism config:
.\run.ps1 Get-SqlServerCpuTopologyAndSchedulerDetails
# Graded OS configuration health check (LPIM, IFI, scheduler affinity):
.\run.ps1 Get-OsConfigurationChecks
# Either against a remote sql server:
.\run.ps1 Get-OsConfigurationChecks -ServerInstance SQLSERVER01
These scripts live in the repo at:
sql/monitoring/instance/Get-SqlServerCpuTopologyAndSchedulerDetails.sqlsql/monitoring/instance/Get-OsConfigurationChecks.sql
Example Output
Get-SqlServerCpuTopologyAndSchedulerDetails returns one row for the instance: the CPU layout the engine sees, the schedulers it built on it, and the three settings that decide how it uses them.

Get-OsConfigurationChecks returns one row of verdicts: a status per check, with the reason in the same cell, so a WARN reads as a sentence rather than a code.

The most common findings on a server nobody has hardened are also the easiest to miss: lpim_status at WARN because Lock Pages in Memory was never granted, and ifi_status at WARN because the service account was never given Perform Volume Maintenance Tasks. Both are a one-line fix and a restart.
Understanding the Results
Get-SqlServerCpuTopologyAndSchedulerDetails
machine_namesql_editionsql_versionlogical_cpu_counthyperthread_ratiosocketscores_per_socketphysical_core_counthyperthread_ratio is logical CPUs per physical package, so a ratio equal to cores_per_socket means no hyper-threading is exposed, and twice it means it is.Act when the numbers do not match what the host was sold as. A VM with 8 logical CPUs on 1 socket and a ratio of 8 is a common shape, and it is not the same thing as 8 cores.numa_node_countonline_schedulerstotal_schedulersmax_workers_countmax_workers_count is the thread ceiling derived from the CPU count.Act when online_schedulers is lower than logical_cpu_count. Something, an affinity mask or an edition cap, is keeping CPUs idle.virtual_machine_type_descsqlserver_start_timemaxdopcost_thresholdaffinity_maskmaxdop 0 means one query may take them all; cost_threshold 5 is the 1990s default; affinity_mask 0 means no pinning.Act when you see 0 and 5 together. That pair is the shipped default on an upgraded instance and is wrong for most modern servers in both directions.Get-OsConfigurationChecks
logical_cpu_countsocketscores_per_socketphysical_core_countnuma_node_countsql_online_schedulerssql_offline_schedulersscheduler_statusscheduler_status is OK when nothing is offline.Act when it reads WARN. An affinity mask, or an edition core cap, is limiting SQL Server to fewer schedulers than the CPUs it can see; check sp_configure 'affinity mask' and the affinity I/O mask next.numa_statusmemory_modellpim_statusphysical_memory_gbmemory_model is CONVENTIONAL until Lock Pages in Memory is granted, when it becomes LOCK_PAGES. lpim_status says the same thing as a verdict with the consequence spelled out.Act when it reads WARN. Windows can trim the buffer pool under memory pressure; grant the Lock pages in memory right to the service account and restart, on any production instance with real memory to protect.max_server_memory_mbmin_server_memory_mbrecommended_max_mem_mbifi_enabledifi_statussql_start_timeuptime_daysSQL Server Edition CPU Limits
Every edition caps the compute a single instance will use, and the cap is enforced through schedulers. SQL Server still builds a visible scheduler for every logical CPU it can see, but only brings the licensed ones online. That gap is what both scripts surface: online_schedulers below logical_cpu_count in Get-SqlServerCpuTopologyAndSchedulerDetails, and a WARN in scheduler_status from Get-OsConfigurationChecks.
| Edition | SQL Server 2016 to 2022 | SQL Server 2025 |
|---|---|---|
| Enterprise, core-based licensing | Operating system maximum | Operating system maximum |
| Enterprise, Server + CAL | 20 cores per instance | 20 cores per instance |
| Standard | Lesser of 4 sockets or 24 cores | Lesser of 4 sockets or 32 cores |
| Web | Lesser of 4 sockets or 16 cores | Not available |
| Express | Lesser of 1 socket or 4 cores | Lesser of 1 socket or 4 cores |
| Developer | Operating system maximum | Operating system maximum |
SQL Server 2025 raised Standard from 24 cores to 32, kept the 4 socket cap, and dropped Web edition altogether. It also splits Developer into Enterprise Developer and Standard Developer, each carrying the features of the edition it is named after. Server + CAL Enterprise isn’t available on new agreements, but older estates still run it, and it is easy to miss: sql_edition reads plain Enterprise Edition, where the uncapped build reads Enterprise Edition: Core-based Licensing. Get Version and Edition pulls the same property across an estate.
Cores on Bare Metal, Logical Processors on a VM
On a physical server the limit counts cores as the operating system reports them, so with hyperthreading on, each licensed core brings both of its threads.
In a virtual machine the limit counts logical processors instead, because the guest can’t see the processor architecture underneath. Every vCPU counts against the cap, whether the host backs it with a full core or a hyperthread. The socket cap bites here too: a Standard 2022 VM given 32 vCPUs on four sockets uses 24 of them, and the same VM presented as 32 single-core sockets uses only 4. That is why the sockets and cores_per_socket columns are worth reading on a VM, not just the total.
How to Tell an Instance Is Capped
Count the scheduler states. Any VISIBLE OFFLINE rows are CPUs the instance can see and won’t use:
SELECT status, COUNT(*) AS schedulers
FROM sys.dm_os_schedulers
GROUP BY status;
An affinity mask gives exactly the same symptom, so check affinity_mask in the topology script before blaming the licence. The error log settles it, because SQL Server writes what it detected and what it will use at every startup:
EXEC xp_readerrorlog 0, 1, N'logical processors';
Both queries together, on my lab VM running SQL Server 2025 CU8 Enterprise Developer:

The log line reads 8 detected and 8 used, and the scheduler states agree: 8 VISIBLE ONLINE, one per logical processor, and no VISIBLE OFFLINE rows. The 8 HIDDEN ONLINE schedulers run the engine’s own internal work and the VISIBLE ONLINE (DAC) row is the dedicated admin connection’s scheduler, so neither counts towards the CPUs your queries get. On a capped server the “using” figure is the lower one, and the difference is your idle CPU. If the answer is a different edition, the edition change runbook covers the move.
Microsoft’s compute capacity limits by edition page has the full rules, and Editions and supported features of SQL Server 2025 has the rest of the 2025 scale limits.
Best Practices
- Run both scripts together, the raw topology from Get-SqlServerCpuTopologyAndSchedulerDetails gives you the numbers that Get-OsConfigurationChecks grades
- Treat
lpim_status = WARNandifi_status = WARNas standing production hardening items on any server with dedicated SQL Server hardware, not just a “nice to have” - Re-check after any VM resize, host migration, or OS patch, all of these settings can silently reset without a corresponding SQL Server change
- Cross-reference
maxdopandcost_thresholdagainst the topology numbers here (sockets, NUMA nodes) rather than tuning them in isolation
Microsoft’s reference covers sys.configurations, sys.dm_os_sys_info and sp_configure in full.
Frequently Asked Questions
Does IFI apply to transaction log files too?
Mostly no. Before SQL Server 2022 every log growth is zero-filled whatever IFI is set to. From SQL Server 2022, log growths of 64 MB or less skip the zero-fill, and larger ones are still zeroed in full. Instant File Initialization: What It Does and How to Enable It covers both.
Is a single NUMA node always a problem?
No, plenty of smaller servers run fine on a single NUMA node. The INFO flag here is only a note that soft-NUMA becomes worth considering once CPU count climbs past a rough threshold, it’s a tuning opportunity, not a misconfiguration.
Why does SQL Server only use some of my cores?
Either the edition caps it or an affinity mask does. Compare online_schedulers with logical_cpu_count, then read the startup line in the error log that ends “based on SQL Server licensing”. If affinity_mask is 0 and the log shows fewer logical processors in use than detected, it’s the edition: Standard stops at 24 cores on SQL Server 2022 and 32 on 2025, Express at 4.
Do the edition limits count hyperthreads on a VM?
Yes. In a virtual machine the limit is based on logical processors, not cores, so every vCPU counts whether it is a full core or a hyperthread on the host. On bare metal it’s the other way round: the limit counts cores, and hyperthreading gives each licensed core two schedulers.
How do I know if my Enterprise instance is capped at 20 cores?
Check sql_edition. Server + CAL Enterprise reports plain Enterprise Edition and is limited to 20 cores per instance; core-based Enterprise reports Enterprise Edition: Core-based Licensing and has no cap beyond the operating system.
Summary
CPU topology and a handful of OS-level settings sit underneath everything else you’ll ever tune on a SQL Server instance, MAXDOP, memory configuration, autogrowth behavior, all of it assumes this layer is already sane. These two scripts turn that assumption into something you can actually verify: the raw numbers, and a graded read on whether LPIM, IFI, and scheduler affinity are configured the way production hardening expects.
Run both as part of any new-server review, and re-check after infrastructure changes, since none of these settings announce themselves when they silently reset.
Related
You may also find these scripts useful:
- Instance Configuration Snapshot
- Instance Configuration Score
- Trace Flags and Resource Governor Configuration
- SQL Server High CPU, the walkthrough that decides working versus waiting before any setting is touched
- DBA Scripts: The Complete Guide, the map across every script on this site
Leave a Reply