ITPub博客

首页 > Linux操作系统 > Linux操作系统 > How to catch SQL Statement's information quickly

How to catch SQL Statement's information quickly

原创 Linux操作系统 作者:Burgess_Liu 时间:2008-09-05 10:51:12 0 删除 编辑

You can fetch all information about SQL Statement with below SQL scirpt. Then you can analyze and improve script  to boost performance.

SELECT creation_time,last_execution_time,total_physical_reads,total_logical_reads  ,total_logical_writes, execution_count , total_worker_time, total_elapsed_time , total_elapsed_time / execution_count avg_elapsed_time,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,((CASE statement_end_offset    WHEN -1 THEN DATALENGTH(st.text) ELSE qs.statement_end_offset END 
-qs.statement_start_offset)/2) + 1) AS statement_text
FROM sys.dm_exec_query_stats AS qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st  ORDER BY total_elapsed_time / execution_count DESC

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15053694/viewspace-441982/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2008-09-05

  • 博文量
    19
  • 访问量
    13994