如何查找引起高CPU的SQL

1.top命令查看

2.找出存在问题的进程信息

ps -ef | grep $PID

3.根据PID查找问题SQL

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
/
 

你可能感兴趣的:(数据库,职场,休闲,top命令,高CPU)