Thursday, 21 June 2018

How to check AG delay in SQL Server

SELECT  ar.replica_server_name, max(datediff(MINUTE, drs.last_commit_time, getdate())) as Delay_inMin

FROM sys.dm_hadr_database_replica_states AS drs INNER JOIN sys.availability_databases_cluster AS adc ON drs.group_id = adc.group_id

AND drs.group_database_id = adc.group_database_id INNER JOIN sys.availability_groups AS ag ON ag.group_id = drs.group_id INNER JOIN sys.availability_replicas AS ar ON drs.group_id = ar.group_id

AND drs.replica_id = ar.replica_id WHERE adc.database_name = 'DatabaseName'  --And replica_server_name <> 'UHSCMPRDROSQL01' And drs.is_local <> 1

group by  ar.replica_server_name 

No comments:

Post a Comment

CPU queries in SQL server

-- Database Wise CPU Utilization report -- CPU_Time(Ms): CPU Time in Milliseconds -- CPUPercent: Let’s say this instance is using 50% CP...