请教 :db2数据库 如何查找出执行时间最长的sql?
1个回答
展开全部
执行时间最长的20条SQL语句(按时间降序排列),可保存为脚本方便调用:
SELECT rows_read / (num_executions + 1) as avg_rows_read,
rows_written / (num_executions + 1) as avg_rows_written,
stmt_sorts / (num_executions + 1) as avg_sorts,
total_exec_time / (num_executions + 1) as avg_exec_time,
substr(stmt_text,1,1000) as SQL_Stmt
FROM SYSIBMADM.SNAPDYN_SQL ORDER BY avg_exec_time desc fetch first 20 rows only;
祝你学习愉快!
SELECT rows_read / (num_executions + 1) as avg_rows_read,
rows_written / (num_executions + 1) as avg_rows_written,
stmt_sorts / (num_executions + 1) as avg_sorts,
total_exec_time / (num_executions + 1) as avg_exec_time,
substr(stmt_text,1,1000) as SQL_Stmt
FROM SYSIBMADM.SNAPDYN_SQL ORDER BY avg_exec_time desc fetch first 20 rows only;
祝你学习愉快!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询