Posts

Showing posts from December 3, 2023

IO Usage at the Database Level and file level

IO Usage at the Database Level We can build out further on this information and present the data in a more usable format and provide exactly what we need vs. what the developer of the DMV/DMF may have foreseen it used for by writing our own query with it incorporated into it. WITH IO_Per_DB AS (SELECT DB_NAME(database_id) AS Db , CONVERT(DECIMAL(12,2), SUM(num_of_bytes_read + num_of_bytes_written) / 1024 / 1024) AS TotalMb FROM sys.dm_io_virtual_file_stats(NULL, NULL) dmivfs GROUP BY database_id) SELECT Db ,TotalMb ,CAST(TotalMb / SUM(TotalMb) OVER() * 100 AS DECIMAL(5,2)) AS [I/O] FROM IO_Per_DB ORDER BY [I/O] DESC; The above query now displays total MBPs and percentage of IO across entire SQL Server per database. If we need to few this in a more detailed perspective , i.e. from the data file view vs. the database, ensuring we identify prospective high IO areas that could become a bottleneck, we could use the following query: WITH IO_Per_DB_Per_File AS (SELECT DB_NAME(dmivfs.database_

The Importance of Real-Time Latch Monitoring in SQL Server

Image
  Crucial for Performance and Responsiveness: Monitoring latches in real-time is essential for maintaining optimal performance and responsiveness in a SQL Server database system. Role of Latches: Latches, being lightweight synchronization primitives, play a pivotal role in safeguarding in-memory structures from concurrent access. Impact of Excessive Latch Contention: Excessive latch contention can lead to queuing and delays, significantly impacting the throughput and responsiveness of the system. Swift Detection of Bottlenecks: Vigilant observation of latch behaviors in real-time allows database administrators to swiftly detect potential bottlenecks. Preventing Severe Performance Issues: Addressing issues before they escalate into severe performance degradation is crucial for maintaining system health. Insights into Dynamic Workloads: Real-time monitoring not only identifies issues promptly but also provides valuable insights into dynamic workloads and interactions within the server. P