<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DBAlife &#187; session_wait</title>
	<atom:link href="http://www.dbalife.com/archives/tag/session_wait/feed" rel="self" type="application/rss+xml" />
	<link>http://www.dbalife.com</link>
	<description>网站系统架构实践</description>
	<lastBuildDate>Wed, 27 Jul 2011 09:57:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>等待事件相关的SQL</title>
		<link>http://www.dbalife.com/archives/144.html</link>
		<comments>http://www.dbalife.com/archives/144.html#comments</comments>
		<pubDate>Wed, 30 Jul 2008 05:16:36 +0000</pubDate>
		<dc:creator>skywalker</dc:creator>
				<category><![CDATA[DBA脚本]]></category>
		<category><![CDATA[DB性能优化]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[数据库管理]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[session_wait]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[等待事件]]></category>

		<guid isPermaLink="false">http://www.dbalife.com/?p=144</guid>
		<description><![CDATA[--求等待事件及其对应的latch col event format a32 col name format a32 select sid,event,p1 as file_id, p2 as "block_id/latch", p3 as blocks,l.name from v$session_wait sw,v$latch l where event not like '%SQL%' and event not like '%rdbms%' and event not like '%mon%' and sw.p2 = l.latch#(+); --求等待事件及其热点对象 col owner format a18 col segment_name format a32 col segment_type format a32 [...]
Related posts:<ol>
<li><a href='http://www.dbalife.com/archives/178.html' rel='bookmark' title='表空间使用状况查询'>表空间使用状况查询</a></li>
<li><a href='http://www.dbalife.com/archives/278.html' rel='bookmark' title='undo相关的sql'>undo相关的sql</a></li>
<li><a href='http://www.dbalife.com/archives/101.html' rel='bookmark' title='ORACLE STATSPACK REPORT输出结果说明'>ORACLE STATSPACK REPORT输出结果说明</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: x-small;">--求等待事件及其对应的latch</span></p>
<p><span style="font-size: x-small;">col event format a32<br />
col name format a32<br />
select sid,event,p1 as file_id, p2 as "block_id/latch", p3 as blocks,l.name<br />
from v$session_wait sw,v$latch l<br />
where event not like '%SQL%' and event not like '%rdbms%'<br />
and event not like '%mon%' and sw.p2 = l.latch#(+);</span><br />
<span style="font-size: x-small;">--求等待事件及其热点对象</span></p>
<p><span style="font-size: x-small;">col owner format a18<br />
col segment_name format a32<br />
col segment_type format a32<br />
select owner,segment_name,segment_type<br />
from dba_extents<br />
where file_id = &amp;file_id and &amp;block_id between block_id<br />
and block_id + &amp;blocks - 1;</span><br />
<span style="font-size: x-small;">--综合以上两条sql，同时显示latch及热点对象(速度较慢)</span></p>
<p><span style="font-size: x-small;">select sw.sid,event,l.name,de.segment_name<br />
from v$session_wait sw,v$latch l,dba_extents de<br />
where event not like '%SQL%' and event not like '%rdbms%'<br />
and event not like '%mon%' and sw.p2 = l.latch#(+) and sw.p1 = de.file_id(+) and p2 between de.block_id and de.block_id + de.blocks - 1;</span><br />
<span style="font-size: x-small;">--如果是非空闲等待事件，通过等待会话的sid可以求出该会话在执行的sql</span></p>
<p><span style="font-size: x-small;">select sql_text<br />
from v$sqltext_with_newlines st,v$session se<br />
where st.address=se.sql_address and st.hashvalue=se.sql_hash_value<br />
and se.sid =&amp;wait_sid order by piece;</span></p>
<p>Related posts:<ol>
<li><a href='http://www.dbalife.com/archives/178.html' rel='bookmark' title='表空间使用状况查询'>表空间使用状况查询</a></li>
<li><a href='http://www.dbalife.com/archives/278.html' rel='bookmark' title='undo相关的sql'>undo相关的sql</a></li>
<li><a href='http://www.dbalife.com/archives/101.html' rel='bookmark' title='ORACLE STATSPACK REPORT输出结果说明'>ORACLE STATSPACK REPORT输出结果说明</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.dbalife.com/archives/144.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

