一、oracle慢查询sql(前200个)
select *@b@ from (select sa.SQL_TEXT,@b@ sa.SQL_FULLTEXT,@b@ sa.EXECUTIONS "执行次数",@b@ round(sa.ELAPSED_TIME / 1000000, 2) "总执行时间",@b@ round(sa.ELAPSED_TIME / 1000000 / sa.EXECUTIONS, 2) "平均执行时间",@b@ sa.COMMAND_TYPE,@b@ sa.PARSING_USER_ID "用户ID",@b@ u.username "用户名",@b@ sa.HASH_VALUE@b@ from v$sqlarea sa@b@ left join all_users u@b@ on sa.PARSING_USER_ID = u.user_id@b@ where sa.EXECUTIONS > 0@b@ order by sa.ELAPSED_TIME desc)@b@ where rownum <= 200;
二、oracle查询频次高sql(前200个)
select *@b@ from (select s.SQL_TEXT,@b@ s.EXECUTIONS "执行次数",@b@ s.PARSING_USER_ID "用户名",@b@ rank() over(order by EXECUTIONS desc) EXEC_RANK@b@ from v$sql s@b@ left join all_users u@b@ on u.USER_ID = s.PARSING_USER_ID) t@b@ where exec_rank <= 200;