BrentOzarULTD / SQL-Server-First-Responder-Kit

sp_Blitz, sp_BlitzCache, sp_BlitzFirst, sp_BlitzIndex, and other SQL Server scripts for health checks and performance tuning.
http://FirstResponderKit.org
Other
3.38k stars 999 forks source link

sp_BlitzFirst: better Azure SQL DB start time detection #3504

Closed BrentOzar closed 7 months ago

BrentOzar commented 7 months ago

Version of the script SELECT @Version = '8.19', @VersionDate = '20240222';

What is the current behavior? Right now to get the Azure SQL DB startup time, we're using an average of several idle wait types:

SELECT wait_type, wait_time_ms,
    NTILE(3) OVER(ORDER BY wait_time_ms) AS grouper
    FROM sys.dm_os_wait_stats w
    WHERE wait_type IN ('DIRTY_PAGE_POLL','HADR_FILESTREAM_IOMGR_IOCOMPLETION','LAZYWRITER_SLEEP',
                        'LOGMGR_QUEUE','REQUEST_FOR_DEADLOCK_SEARCH','XE_TIMER_EVENT')

When it's available, I'd rather use the more accurate sys.dm_cloud_database_epoch DMV, the last_role_transition_time column.