ITPub博客

首页 > 数据库 > Oracle > 查询执行慢的SQL语句

查询执行慢的SQL语句

Oracle 作者:xypincle 时间:2017-04-12 17:27:03 0 删除 编辑

  1. select s.sql_text,
  2.        s.sql_fulltext,
  3.        s.sql_id,
  4.        round(elapsed_time / 1000000 / (case
  5.                when (executions = 0 or nvl(executions, 1) = 1) then 1 else executions end),2) "执行时间'S'",
  6.        s.executions "执行次数",
  7.        s.optimizer_cost "COST",
  8.        s.sorts,
  9.        s.module, --连接模式(jdbc thin client:程序)
  10.        -- s.locked_total,
  11.        s.physical_read_bytes "物理读",
  12.        -- s.physical_read_requests "物理读请求",
  13.        s.physical_write_requests "物理写",
  14.        -- s.physical_write_bytes "物理写请求",
  15.        s.rows_processed "返回行数",
  16.        s.disk_reads "磁盘读",
  17.        s.direct_writes "直接路径写",
  18.        s.parsing_schema_name,
  19.        s.last_active_time
  20.   from gv$sqlarea s
  21.  where round(elapsed_time / 1000000 / (case when (executions = 0 or nvl(executions, 1) = 1) then 1 else executions end),2) > 5 --100 0000微秒=1s
  22.    --and s.parsing_schema_name = user
  23.    and to_char(s.last_load_time, 'YYYY-MM-DD') = to_char(sysdate, 'YYYY-MM-DD')
  24.    and s.command_type in (2, 3, 5, 6, 189)
  25.  order by "执行时间'S'" desc;

  1. /*  SQL中 COMMAND_TYPE意义:
  2. 2:INSERT
  3. 3:SELECT
  4. 6:UPDATE
  5. 7:DELETE
  6. 189:MERGE
  7. 详情可通过查找V$SQLCOMMAND视图  */


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

下一篇: ORACLE锁机制
请登录后发表评论 登录
全部评论

注册时间:2013-05-11

  • 博文量
    208
  • 访问量
    212343