linux平台下,我们一般通过TOP命令,查看性能消耗最大的进程,如果看到是oracle进行,那么就需要通过进程号,查询该进程当前执行的SQL语句,网上百度有很多SQL,我一般通过下面的方式进行查找:

通过操作系统上的PID找出相应的SQL语句的SID:

SELECT s.sid, p.spid FROM v$session s, v$process p WHERE s.paddr = p.addr  AND  < p.spid = <os pid> 


然后通过SID找出相应的SQL语句的具体内容:


SELECT s.sid, s.status, q.sql_text FROM v$session s, v$sqltext q WHERE s.sql_hash_value = q.hash_value AND s.sql_address = q.address AND s.sid = <sid> order by q.piece;

合并一

 
 
SELECT   /*+ ORDERED */
         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
/


合并二:

Select s.Sid, s.Status, q.Sql_Text
From V$session s, V$sqltext q
Where s.Sql_Hash_Value = q.Hash_Value And s.Sql_Address = q.Address And
                        s.Sid In (Select s.Sid
                                                                 From V$session s, V$process p
                                                                 Where s.Paddr = p.Addr And  p.Spid = '&pid' )
Order By q.Piece;


GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐