0x1 场景
很多时候我们可以看到 top 中有些 Oracle进程持续占用很高的 CPU 或者内存,但是无奈会话太多,不能确定是哪个导致,那么应该如何定位呢?
0x2 查询sql
直接执行此SQL,根据提示输入系统进程号即可
Enter the os pid and find the sql id
select sid, sql_id from v$session s, v$process p
where s.paddr = p.addr
and p.spid = &OS_PID;
根据上面的SQL返回内容,替换下面的 sql_id
Enter the sql_id to find the sql_text
set long 1000
set pages 1000 lines 1000
col sql_text for a100
select sql_text
from v$sql
where sql_id = '&sql_id';
0x3 其他
仍然会存在不准确的现象,因为有些事务很大,包含很多SQL,可能当前查询出来的sql是整个事务中性能影响较小的,已经错过了最佳的执行时间。
评论