How to Identify SID Based on OS PID in Oracle

In order to drill down database performance issue like top memory, I/O and CPU consumers, you need to check SID from PID called the OS Process ID.

Once you get the SID, you can check the sql_id from v$session and corresponding sql text from v$sql view in Oracle.

Query To Check SID From OS PID

col sid format 99999
col username format a20
col osuser format a15
select p.spid,s.sid, s.serial#,s.username, s.osuser
from gv$session s, gv$process p
where s.paddr= p.addr
and p.spid='&spid'
order by p.spid;