博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

查询性能问题

Posted on 2012-05-25 11:08  奥客  阅读(240)  评论(0编辑  收藏  举报

select
 se.action,
 pr.SPID,
 se.osuser,
 se.machine,
 se.program,
 se.module,
 se.logon_time,
 sa.MODULE,
       sl.OPNAME,
       to_char(sl.start_time, 'yyyy-mm-dd hh24:mi:ss') start_time,
       sa.SQL_TEXT,
       pr.*,
       '||',
       se.*
from v$session se, v$process pr, v$session_longops sl, v$sqlarea sa
where se.PADDR = pr.ADDR(+)
and se.SID = sl.SID(+)
and sl.sql_hash_value = sa.hash_value(+)
--and se.module like  '%' || upper('emily_li') || '%'
--and sl.START_TIME is not null
--and pr.SPID in (27584)  --依操作系统进程ID查
and se.SID in (337) --依会话ID查


  
--查询IO
SELECT  si.physical_reads,se.osuser, se.sid,se.serial#,pr.SPID,se.username,se.status,se.terminal,se.program,se.MODULE,se.sql_address,st.event,st.p1text,si.block_changes
,se.*
FROM v$session se, v$session_wait st,v$sess_io si,v$process pr
WHERE st.sid=se.sid  AND st.sid=si.sid
AND se.PADDR=pr.ADDR AND se.sid>6 
AND st.wait_time=0
ORDER BY physical_reads DESC

 

--查询等待  
Select  s.osuser,  s.username,s.program,s.status,se.event,se.total_waits,se.total_timeouts,se.time_waited,se.average_wait
,s.*
from v$session s, v$session_event se
Where s.sid=se.sid And se.event not like 'SQl*Net%'And s.status ='ACTIVE'And s.username is not null
order by total_waits desc

 

--批量杀进程查询IO
SELECT   'kill -9 ' || to_char( pr.SPID )
, si.physical_reads,se.osuser, se.sid,se.serial#,pr.SPID,se.username,se.status,se.terminal,se.program,se.MODULE,se.sql_address,st.event,st.p1text,si.block_changes
FROM v$session se, v$session_wait st,v$sess_io si,v$process pr
WHERE st.sid=se.sid  AND st.sid=si.sid
AND se.PADDR=pr.ADDR AND se.sid>6 
AND st.wait_time=0
and se.program='dis51usr.exe'
--and se.status='INACTIVE'
and to_char(se.logon_time,'yyyy-mm-dd hh24:mm:ss')<'2012-05-24 09:10:00'
and si.physical_reads>100000
group by pr.SPID


 
  

--查询死锁  
select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid