If you are suffering from poorly performing linked server queries, you may wants to investigate the Linked Server CPU utilisation statistics. Following T-SQL script retrieves information such as SQL Process utilisation, System Idle time and Other Process utilization for a preconfigured MS SQL Linked server.
1 2 3 4 5 6 7 8 9 10 11 12 |
DECLARE @LinkedServerName varchar(128) SET @LinkedServerName='Linked Server Name' -- Set your linked server name here DECLARE @SQL NVARCHAR(MAX); SELECT @SQL = 'SELECT record_time,SQLProcessUtilization,SystemIdle,100 - SystemIdle - SQLProcessUtilization AS OtherProcessUtilization' SELECT @SQL = @SQL +' FROM (SELECT record.value(''(./Record/@id)[1]'', ''bigint'') AS record_id, record.value(''(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]'', ''bigint'') AS SystemIdle,' SELECT @SQL = @SQL +' record.value(''(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]'', ''bigint'') AS SQLProcessUtilization,record_time' SELECT @SQL = @SQL +' FROM ( select dateadd (ms, r.[timestamp] - sys.ms_ticks, getdate()) as record_time, cast(r.record as xml) record ' SELECT @SQL = @SQL +' from ['+@LinkedServerName+'].master.sys.dm_os_ring_buffers r cross join ['+@LinkedServerName+'].master.sys.dm_os_sys_info sys where ring_buffer_type=''RING_BUFFER_SCHEDULER_MONITOR'' AND record LIKE ''%<SystemHealth>%'') AS x ) AS y ORDER By record_time DESC' EXEC(@SQL) |
Leave a Comment