zoukankan      html  css  js  c++  java
  • oracle 实时查询最耗CPU资源的SQL语句

    1. 先通过top命令查看产用资源较多的spid号

    2.查询当前耗时的会话ID,用户名,sqlID等: select sid,serial#,machine,username,program,sql_hash_value,sql_id,        to_char(logon_time,'yyyy/mm/dd hh24:mi:ss') as login_time from v$session where paddr in (select addr from v$process where spid in ('5648612','256523'));

    3. 如果上一步sql_id或者 hash_value不为空,则可用v$sqlarea查出当前正在使用的sql select sql_text   from v$sqltext_with_newlines   where hash_value = &hash_value order by piece;
    select * from v$sql where sql_id=''

    ---CSDN 网友提供的----

    SELECT sql_text   FROM v$sqltext a WHERE (a.hash_value, a.address) IN        (SELECT DECODE(sql_hash_value, 0, prev_hash_value, sql_hash_value),                DECODE(sql_hash_value, 0, prev_sql_addr, sql_address)           FROM v$session b          WHERE b.paddr = (SELECT addr FROM v$process c WHERE c.spid = '&pid')) ORDER BY piece ASC

  • 相关阅读:
    gTest&gMock learning
    机器学习 delay learning
    c++ learning
    2017 湘潭邀请赛&JSCPC G&J
    mapreduce&GFS&bigtable learning
    golang learning
    高斩仙的北京历险记
    python learning
    Codeforces Round #448 (Div. 2) B
    python之callable
  • 原文地址:https://www.cnblogs.com/zwl715/p/3816490.html
Copyright © 2011-2022 走看看