Get the App
SLTechnology News&Howtos  ›  Database  › 

Sample code for AGStatus SQL in the database

Shulou Source: shulou.com Published: 2022-05-31 12:37:40 11月16日 Update

Editor to share with you the sample code of AGStatus SQL in the database, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Select n.grouppapername REMOTE' END as is_local,rs.connected_state_desc WHEN rs.is_local = 1 THEN local 'ELSE' REMOTE' END as is_local,rs.connected_state_desc CASE WHEN drs.suspend_reason_desc='SUSPEND_FROM_USER' THEN 'user manually suspended data movement' WHEN drs.suspend_reason_desc='SUSPEND_FROM_REDO' THEN 'error in redo phase' WHEN drs.suspend_reason_desc='SUSPEND_FROM_CAPTURE' THEN 'error while capturing log on master copy' WHEN drs.suspend_reason_desc='SUSPEND_FROM_UNDO' THEN 'error in undo phase (see error log) 'WHEN drs.suspend_reason_desc='SUSPEND_FROM_XRF_UPDATE' THEN' cannot find the public log point (see error log) 'END as is_suspended -- whether the database hangs and causes drs.synchronization_health_desc,ISNULL (drs.redo_queue_size,0) as redo_queue_size,-- the number of log records in the log files of the secondary copy that have not yet been redone (KB) ELSE CAST (ISNULL (drs.log_send_queue_size,0) * 1./ISNULL (drs.log_send_rate,0) AS DECIMAL (18Magne2)) CASE WHEN ISNULL (drs.redo_rate) 0) = 0 THEN 0END as redo_need_time-it takes time for the log record redo in the secondary copy to complete (seconds) join sys.dm_hadr_availability_replica_cluster_states csjoin sys.dm_hadr_availability_replica_states rsjoin sys.dm_hadr_database_replica_states drswhere rs.connected_state_desc'CONNECTED'or drs.is_suspended0or CASE WHEN ISNULL (drs.redo_rate,0) = 0 THEN 0 ELSE CAST (ISNULL (drs.redo_queue_size,0) * 1./ISNULL (drs.redo_rate) 0) AS DECIMAL (18Pol 2)) END > 100

The above is all the contents of the article "sample Code of AGStatus SQL in the Database". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Logs data databases copies articles code examples content errors stages assistance not much China and Japan reasons most not yet manual files time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Huawei Shulou Information Linux OPPO Reno