arjun9916
arjun9916

Reputation: 91

how to find cpu cores used by sql instance in cmd

I dont have access to Management studio, but i want to check how many cores are used by a SQL instance, How to find it without Management studio.

I had tried using

select scheduler_id,cpu_id, status, is_online 
from sys.dm_os_schedulers where status='VISIBLE ONLINE'

for the servers which I have access to management studio.

Upvotes: 1

Views: 9885

Answers (2)

Ben Thul
Ben Thul

Reputation: 32707

If you have wmi access, you can get this from the win32_processor class. Here's a quick powershell script that (at least in my limited testing) seems to work.

(get-wmiobject -query 'select * from win32_processor' | Measure-Object).count

Upvotes: 0

Bryan
Bryan

Reputation: 17693

I'm not aware of SQL Server tracking physical processor cores, but it can be calculated using the logical cpu_count and hyperthread_ratio values returned from sys.dm_os_sys_info.

The below query was taken from Glenn Berry's diagnostic queries:

SELECT cpu_count AS [Logical CPU Count],
       hyperthread_ratio AS [Hyperthread Ratio],
       cpu_count/hyperthread_ratio AS [Physical CPU Count]
FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE);

Upvotes: 2

Related Questions