ããã·ã¼ã¸ã£ ãã£ãã·ã¥ã®ä¸èº«ãåç §ï¼dm_exec_cached_plansï¼
TechEd 2009 ã§ã®ç§ã®ã·ã¢ã¿ã¼ã»ãã·ã§ã³ãSQL Server åç管çãã¥ã¼åå ¥éãã§ç´¹ä»ãããããã·ã¼ã¸ã£ ãã£ãã·ã¥ã®ä¸èº«ããåç §ã§ããã¹ã¯ãªããã§ããDMVï¼åç管çãã¥ã¼ï¼ã® dm_exec_cached_plans ã¨ãåç管çé¢æ°ï¼DMFï¼ã® dm_exec_query_planãdm_exec_sql_text ãå©ç¨ãã¦ãã¾ãã
SELECT text AS sqltext, query_plan AS å®è¡ãã©ã³, usecounts, * FROM sys.dm_exec_cached_plans CROSS APPLY sys.dm_exec_query_plan (plan_handle) CROSS APPLY sys.dm_exec_sql_text( plan_handle )
ããã·ã¼ã¸ã£ ãã£ãã·ã¥ã® objtype ãã¨ã®éè¨ï¼dm_exec_cached_plansï¼
TechEd 2009 ã§ã®ç§ã®ã·ã¢ã¿ã¼ã»ãã·ã§ã³ãSQL Server åç管çãã¥ã¼åå ¥éãã§ç´¹ä»ãããããã·ã¼ã¸ã£ ãã£ãã·ã¥ã® objtype ãã¨ã®éè¨ããåå¾ã§ããã¹ã¯ãªããã§ããDMVï¼åç管çãã¥ã¼ï¼ã® dm_exec_cached_plans ã objtype 㧠GROUP BY ãã¦ãã¾ãã
SELECT objtype , SUM(size_in_bytes) / 1024 AS 使ç¨ãµã¤ãºKB FROM sys.dm_exec_cached_plans GROUP BY objtype ORDER BY 2 DESC
CPU å©ç¨ã®å¤ãã¯ã¨ãª TOP 100ï¼dm_exec_query_statsï¼
TechEd 2009 ã§ã®ç§ã®ã·ã¢ã¿ã¼ã»ãã·ã§ã³ãSQL Server åç管çãã¥ã¼åå ¥éãã§ç´¹ä»ãããCPU å©ç¨ã®å¤ãã¯ã¨ãª TOP 100ããåå¾ã§ããã¹ã¯ãªããã§ããDMVï¼åç管çãã¥ã¼ï¼ã® dm_exec_query_stats ã¨ãåç管çé¢æ°ï¼DMFï¼ã® dm_exec_sql_text ãå©ç¨ãã¦ãã¾ãã
SELECT TOP 100 total_elapsed_time / execution_count / 1000.0 AS [å¹³åå®è¡æéï¼ããªç§ï¼] , total_worker_time / execution_count / 1000.0 AS [å¹³å CPU æéï¼ããªç§ï¼] , total_physical_reads / execution_count AS [å¹³åç©çI/O æ°] , (total_logical_reads + total_logical_writes) / execution_count AS [å¹³åè«çI/O æ°] , SUBSTRING(text, (statement_start_offset / 2) + 1, ((CASE statement_end_offset WHEN -1 THEN DATALENGTH(text) ELSE statement_end_offset END - statement_start_offset) / 2) + 1) AS sqltext FROM sys.dm_exec_query_stats CROSS APPLY sys.dm_exec_sql_text(sql_handle) ORDER BY 2 DESC
I/O æ°ã®å¤ãã¯ã¨ãª TOP 100ï¼dm_exec_query_statsï¼
TechEd 2009 ã§ã®ç§ã®ã·ã¢ã¿ã¼ã»ãã·ã§ã³ãSQL Server åç管çãã¥ã¼åå ¥éãã§ç´¹ä»ãããI/O æ°ã®å¤ãã¯ã¨ãª TOP 100ããåå¾ã§ããã¹ã¯ãªããã§ããDMVï¼åç管çãã¥ã¼ï¼ã® dm_exec_query_stats ã¨ãåç管çé¢æ°ï¼DMFï¼ã® dm_exec_sql_text ãå©ç¨ãã¦ãã¾ãã
SELECT TOP 100 total_physical_reads / execution_count AS [å¹³åç©çI/O æ°] , (total_logical_reads + total_logical_writes) / execution_count AS [å¹³åè«çI/O æ°] , total_elapsed_time / execution_count / 1000.0 AS [å¹³åå®è¡æéï¼ããªç§ï¼] , total_worker_time / execution_count / 1000.0 AS [å¹³åCPU æéï¼ããªç§ï¼] , SUBSTRING(text, (statement_start_offset / 2) + 1, ((CASE statement_end_offset WHEN -1 THEN DATALENGTH(text) ELSE statement_end_offset END - statement_start_offset) / 2) + 1) AS sqltext FROM sys.dm_exec_query_stats CROSS APPLY sys.dm_exec_sql_text(sql_handle) ORDER BY 1 DESC, 2 DESC
tempdb ã®ãã¡ã¤ã«ã®ä½¿ç¨ç¶æ³ï¼dm_db_file_space_usageï¼
TechEd 2009 ã§ã®ç§ã®ã·ã¢ã¿ã¼ã»ãã·ã§ã³ãSQL Server åç管çãã¥ã¼åå ¥éãã§ç´¹ä»ãããtempdb ã®ãã¡ã¤ã«ã®ä½¿ç¨ç¶æ³ããåå¾ã§ããã¹ã¯ãªããã§ããDMVï¼åç管çãã¥ã¼ï¼ã® dm_db_file_space_usage ãã¯ã¨ãªãã¦ãã¾ãã
SELECT * FROM sys.dm_db_file_space_usage
tempdb ã®æ¥ç¶ãã¨ã®ä½¿ç¨ç¶æ³ï¼dm_db_session_space_usageï¼
TechEd 2009 ã§ã®ç§ã®ã·ã¢ã¿ã¼ã»ãã·ã§ã³ãSQL Server åç管çãã¥ã¼åå ¥éãã§ç´¹ä»ãããtempdb ã®æ¥ç¶ãã¨ã®ä½¿ç¨ç¶æ³ããåå¾ã§ããã¹ã¯ãªããã§ããDMVï¼åç管çãã¥ã¼ï¼ã® dm_db_session_space_usage ãã¯ã¨ãªãã¦ãã¾ãã
SELECT * FROM sys.dm_db_session_space_usage
tempdb ã®ã¿ã¹ã¯ãã¨ã®ä½¿ç¨ç¶æ³ï¼dm_db_task_space_usageï¼
TechEd 2009 ã§ã®ç§ã®ã·ã¢ã¿ã¼ã»ãã·ã§ã³ãSQL Server åç管çãã¥ã¼åå ¥éãã§ç´¹ä»ãããtempdb ã®ã¿ã¹ã¯ãã¨ã®ä½¿ç¨ç¶æ³ããåå¾ã§ããã¹ã¯ãªããã§ããDMVï¼åç管çãã¥ã¼ï¼ã® dm_db_task_space_usage ãã¯ã¨ãªãã¦ãã¾ãã
SELECT * FROM sys.dm_db_task_space_usage
-- dm_exec_requests 㨠JOIN ãã¦æ¥ç¶æ å ± -- dm_exec_query_plan ã§å®è¡ãã©ã³ãåå¾å¯è½ SELECT query_plan, text, * FROM sys.dm_db_task_space_usage t INNER JOIN sys.dm_exec_requests r ON t.session_id = r.session_id AND t.request_id = r.request_id CROSS APPLY sys.dm_exec_sql_text( sql_handle ) CROSS APPLY sys.dm_exec_query_plan (plan_handle)