标签:
原文: T-SQL性能调整——信息收集
IO信息(自服务器启动开始)
--Database IO analysis WITH IOFORDATABASE AS ( SELECT DB_NAME(VFS.database_id) AS DatabaseName , CASE WHEN smf.type = 1 THEN ‘LOG_FILE‘ ELSE ‘DATA_FILE‘ END AS DatabaseFile_type , SUM(VFS.num_of_bytes_written) AS IO_Write , SUM(VFS.num_of_bytes_read) AS IO_Read , SUM(VFS.num_of_bytes_read + VFS.num_of_bytes_written) AS Total_IO , SUM(VFS.io_stall) AS IO_STALL FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS VFS JOIN sys.master_files AS smf ON VFS.database_id = smf.database_id AND VFS.file_id = smf.file_id GROUP BY DB_NAME(VFS.database_id) , smf.type ) SELECT ROW_NUMBER() OVER ( ORDER BY io_stall DESC ) AS RowNumber , Databasename , databasefile_type , CAST(1.0 * IO_Read / ( 1024 * 1024 ) AS DECIMAL(12, 2)) AS IO_Read_MB , CAST(1.0 * IO_Write / ( 1024 * 1024 ) AS DECIMAL(12, 2)) AS IO_Write_MB , CAST(1.0 * Total_IO / ( 1024 * 1024 ) AS DECIMAL(12, 2)) AS IO_TOTAL_MB , CAST(IO_STALL / 1000 AS DECIMAL(12, 2)) AS IO_STALL_Seconds , CAST(100. * IO_STALL / SUM(IO_STALL) OVER ( ) AS DECIMAL(10, 2)) AS IO_STALL_Pct FROM IOFORDATABASE ORDER BY IO_STALL_Seconds DESC
统计信息:
1、使用DBCC SHOW_STATISTICS()命令检查。可以查看柱状图和密度信息。
2、使用sys.stats 视图查看表中有多少统计信息。
3、使用sys.stats_columns视图查看哪些列是统计信息的组成部分。
标签:
原文地址:http://www.cnblogs.com/lonelyxmas/p/4314966.html