Process | statement | execution
To find the most resource-intensive SQL, we can first use tools such as top to find the process of the best resource (remember the process number), for example, the operating system process number is 1217, and then locate the process address in v$process based on the process number (V$PROCESS.SPID) (v$ PROCESS.ADDR), then finds the corresponding SID (V$session.sid) in v$session based on this address, and then finds the corresponding hash alue (v$session) based on this SID. Sql_hash_value), and then according to this hash alue, find the corresponding SQL statement (Sql_text) in the V$sqltext, $sql, V$sqlarea view.
For example:
oracle@cs_db02:/arch1/lunar/tools > whoistopsql.sh 6799
Connected.
SID serial# USERNAME osuser MACHINE program PRO CESS To_char (Logon_time,
---------- ---------- ------------------------------ ------------------------------ ------------------------------ - --------------------------------------- ------------ -------------------
483 1224 PORTAL www16 bj_wap03 JDBC Thin Clie NT 2004/09/22 02:21:03
Sql_text
----------------------------------------------------------------
SELECT * from spinfo where SpID =: 1
Oracle@cs_db02:/arch1/lunar/tools >