当一个用户坐在终端前提交了一个查询却等不出结果,这很是让人恢心的。他们很希望语句运行正常,
但却不知道实际上怎么样.让我们找出一个办法来消除他们的担心。
1.第一个问题当然指的是我们正在提交的是哪个会话?用户可以在做其他事情用如下的语句得到它:
select sid from v$mystat where rownum =1;
①如果用户有一个唯一的用户名,那么你可以用如下的语句得到哪个SID,比如查询用户John的SID。
select sid,machine,osuser,module from v$session where username='JOHN';
sid machine osuser module
---- -------------------- -----------------------------
150 MSHOME\JOHN-LAPTOP JOHN?Weeg SQL*Plus
②如果是共享用户名被使用的情况,需要看一下哪些会话正在运行:
select a.sid,a.last_call_et,b.sql_text from
v$session a , v$sqltext b
where a.usename is not null
and a.status='ACTIVE'
and a.sql_address=b.address;
③ 我们知道通常情况下语句执行伴随着等待,正在执行CPU操作或是执行I/O操作。
通过v$sessstat,v$sessio,v$session_wait这三张表我们可以知道一些信息.
select a.sid,a.value session_cpu,c.physical_reads,
c.consistent_gets,d.event,d.seconds_in_wait
from v$sessstat a, v$statname b, v$sess_io c, v$session_wait d
where a.sid=150
and b.name='CPU used by this session'
and a.statistic# = b.statistic#
and a.sid=c.sid
and a.sid=b.sid;
④ 查询看是否为几个事件标识存在问题.
select owner,segment_name,segment_type from
(select p1 file#,p2 block# from v$session_wait where sid=150
and event in ('buffer busy waits','db file sequential read','db file scattered read',
'free buffer waits')) b,dba_extents a
where a.file_id = b.file#
and b.block# between a.block_id and (a.block_id + blocks -1);
现在我们可以告诉那些不安的用户他们执行的语句在等待一些其他的资源。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22578826/viewspace-751931/
,如需转载,请注明出处,否则将追究法律责任。