Matticusau / sqlops-alwayson-insights

SqlOps Studio AlwaysOn Insights Extension
MIT License
11 stars 9 forks source link

Insight: Auto seeding #3

Open Matticusau opened 6 years ago

Matticusau commented 6 years ago

Add an insight for autoseeding based on this existing SQL I wrote https://github.com/Microsoft/DataInsightsAsia/blob/Dev/Scripts/AlwaysOn/AutomaticSeeding.sql

Matticusau commented 6 years ago

Try and work on this for next version to include a better summary

SELECT 
CONVERT(DATE, autos.start_time) [start_date]
, ag.name [ag_name]
, db.database_name
, autos.current_state
, COUNT(autos.current_state) [count]
FROM sys.dm_hadr_automatic_seeding autos 
    JOIN sys.availability_databases_cluster db 
        ON autos.ag_db_id = db.group_database_id
    JOIN sys.availability_groups ag 
        ON autos.ag_id = ag.group_id
GROUP BY CONVERT(DATE, autos.start_time)
    , ag.name
    , db.database_name
    , autos.current_state
Matticusau commented 6 years ago

Some working queries for further exploration

SELECT 
    CONVERT(DATE, autos.start_time) [start_date]
    -- , ag.name [ag_name]
    -- , db.database_name
    , autos.current_state
    -- , autos.number_of_attempts
    , SUM(autos.number_of_attempts) [total_attempts]
FROM sys.dm_hadr_automatic_seeding autos 
    JOIN sys.availability_databases_cluster db 
        ON autos.ag_db_id = db.group_database_id
    JOIN sys.availability_groups ag 
        ON autos.ag_id = ag.group_id
--WHERE autos.current_state = 'FAILED'
    --AND autos.failure_state <> 21 --Seeding Check Message Timeout
GROUP BY CONVERT(DATE, autos.start_time)
    , ag.name
    , db.database_name
    , autos.current_state
    --, autos.number_of_attempts

select autos.*
FROM sys.dm_hadr_automatic_seeding autos 
    JOIN sys.availability_databases_cluster db 
        ON autos.ag_db_id = db.group_database_id
    JOIN sys.availability_groups ag 
        ON autos.ag_id = ag.group_id