Published on

January 24, 2012

Understanding Virtual Processors in SQL Server

Have you ever wondered how many virtual processors are available for SQL Server? This is a common question that many database administrators and developers have. In this blog post, we will explore different methods to identify the number of virtual processors in SQL Server.

If you are using SQL Server 2005, 2008, 2008R2, or 2012, you can use the following script:

SELECT cpu_count
FROM sys.dm_os_sys_info

This script will give you the number of virtual processors available for these versions of SQL Server.

However, if you are using SQL Server 2000, you can use the following script:

CREATE TABLE #TempTable
([Index] VARCHAR(2000),
[Name] VARCHAR(2000),
[Internal_Value] VARCHAR(2000),
[Character_Value] VARCHAR(2000)) ;

INSERT INTO #TempTable
EXEC xp_msver;

SELECT Internal_Value AS VirtualCPUCount
FROM #TempTable
WHERE Name = 'ProcessorCount';

DROP TABLE #TempTable

These scripts will help you identify the number of virtual processors in your SQL Server instance.

Additionally, SQL Server MVP Glenn Berry has shared another script that is applicable to SQL Server 2005 and later versions:

SELECT cpu_count AS [Logical CPU Count], hyperthread_ratio AS Hyperthread_Ratio,
cpu_count/hyperthread_ratio AS Physical_CPU_Count,
physical_memory_in_bytes/1048576 AS Physical_Memory_in_MB,
sqlserver_start_time, affinity_type_desc -- (affinity_type_desc is only in 2008 R2)
FROM sys.dm_os_sys_info

This script provides more detailed information about the logical CPU count, hyperthread ratio, physical CPU count, physical memory, SQL Server start time, and affinity type.

If you know any other reliable method to get the count of logical CPUs, please share it in the comments section below. We will update this blog post with due credit.

Understanding the number of virtual processors in SQL Server is important for optimizing performance and resource allocation. By knowing the available resources, you can make informed decisions when configuring your SQL Server environment.

Thank you for reading this blog post. We hope you found it helpful in understanding virtual processors in SQL Server.

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.