<?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>惜分飞 &#187; _optimizer_ads_use_result_cache</title>
	<atom:link href="https://www.xifenfei.com/tag/_optimizer_ads_use_result_cache/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Sun, 22 Nov 2026 15:21:14 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>12.1中出现大量Result Cache: RC Latch处理</title>
		<link>https://www.xifenfei.com/2016/05/result-cache-rc-latch.html</link>
		<comments>https://www.xifenfei.com/2016/05/result-cache-rc-latch.html#comments</comments>
		<pubDate>Sun, 29 May 2016 02:23:57 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Oracle性能优化]]></category>
		<category><![CDATA[Result Cache: RC Latch]]></category>
		<category><![CDATA[_optimizer_ads_use_result_cache]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=6386</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2016/05/result-cache-rc-latch.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2016/05/result-cache-rc-latch.html" target="_blank">12.1中出现大量Result Cache: RC Latch处理</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>昨天有个朋友找到我说他们的12.1的库在业务高峰期非常慢，希望我们给予优化支持,经过awr分析，定位到问题为latch free问题,具体定位为:Result Cache: RC Latch.<br />
<strong>优化之前awr部分信息</strong><br />
awr整体负载情况，证明当前这个库已经比较忙，业务反馈很慢<br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/awr1.jpg" alt="awr1" width="606" height="214" class="alignleft size-full wp-image-6392" /><br />
<hr />
addr信息和top wait信息，确定是latch free问题比较突出<br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/awr2.jpg" alt="awr2" width="599" height="188" class="alignleft size-full wp-image-6391" /><br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/awr3.jpg" alt="awr3" width="612" height="214" class="alignleft size-full wp-image-6390" /><br />
<hr />
latch信息统计和ash信息，找出来突出的latch,定位为Result Cache: RC Latch引起该问题<br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/awr4.jpg" alt="awr4" width="615" height="186" class="alignleft size-full wp-image-6389" /><br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/awr5.jpg" alt="awr5" width="790" height="206" class="alignleft size-full wp-image-6388" /><br />
<hr />
补充大量异常sql<br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/awr6.jpg" alt="awr6" width="877" height="214" class="alignleft size-full wp-image-6387" /><br />
<hr />
类似sql语句</p>
<pre class="brush: sql; title: ; notranslate">
SELECT /* DS_SVC */ /*+ dynamic_sampling(0) no_sql_tune no_monitoring optimizer_features_enable(default) no_parallel */
 SUM(C1) FROM (SELECT /*+ qb_name(&quot;innerQuery&quot;) INDEX_FFS( &quot;ACCOUNT&quot; &quot;ACC_USER_ID&quot;) */ 
1 AS C1 FROM &quot;ACCOUNT&quot; SAMPLE BLOCK(39.3701, 8) SEED(1) &quot;ACCOUNT&quot; WHERE ( &quot;ACCOUNT&quot;.USER_ID IS NOT NULL)) innerQuery
</pre>
<p><strong>查询mos发现</strong><br />
The cause of this issue is automatic dynamic statistics which is enabled by default in 12c automatically decides whether dynamic statistics are useful and which statistics level to use for all SQL statements. It collects dynamic statistics when the optimizer deems it necessary.<br />
When Automatic Dynamic Sampling is used for the SQL statements, it can decide, based upon these statistics, that a better response time could be achieved by using the result cache for those queries. This can cause heavy usage of the result cache leading to the contention on latch free for &#8220;Result Cache: RC Latch&#8221;.<br />
也就是说,12c在自动采样有改进，而且默认使用result cache特性，从而引起该问题，即使你设置了 RESULT_CACHE_MODE = MANUAL，依旧会有大量动态采样引起 Result Cache: RC Latch，彻底解决给问题就是通过隐含参数禁止Automatic Dynamic Statistics使用result cache</p>
<pre class="brush: sql; title: ; notranslate">
alter system set &quot;_optimizer_ads_use_result_cache&quot; = FALSE;
</pre>
<p><strong>设置该参数之后效果</strong><br />
这里看，通过上述处理后，系统db time 大量减少，业务反馈已经运行正常<br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/hawr1.jpg" alt="hawr1" width="609" height="204" class="alignleft size-full wp-image-6396" /><br />
<hr />
latch free和Result Cache: RC Latch已经基本上消失<br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/hawr2.jpg" alt="hawr2" width="600" height="288" class="alignleft size-full wp-image-6395" /><br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/hawr3.jpg" alt="hawr3" width="602" height="197" class="alignleft size-full wp-image-6394" /><br />
<img src="//www.xifenfei.com/wp-content/uploads/2016/05/hawr4.jpg" alt="hawr4" width="543" height="177" class="alignleft size-full wp-image-6393" /><br />
<hr />
当然这个异常是由于动态采样导致,可以通过收集数据库统计信息，设置动态采样级别，也可以从一定程度上缓解该情况.<br />
<strong>参考mos</strong><br />
Very Long Parse Time for Queries in InMemory Database (Doc ID 2102106.1)<br />
High &#8220;Latch Free&#8221; Waits with Contention on &#8216;Result Cache: RC Latch&#8217; when RESULT_CACHE_MODE = MANUAL on Oracle 12c (Doc ID 2002089.1)</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/01/vmware-vsphere6-0-%e5%88%9d%e8%af%95.html" rel="bookmark" class="crp_title">VMware vSphere6.0 初试</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/01/vsphere-ssh%e7%99%bb%e9%99%86%e9%85%8d%e7%bd%ae.html" rel="bookmark" class="crp_title">vSphere ssh登陆配置</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/04/oracle-7-3-4-%e6%88%aa%e5%9b%be%e6%ac%a3%e8%b5%8f.html" rel="bookmark" class="crp_title">ORACLE 7.3.4 截图欣赏</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/07/_offline_rollback_segments-_corrupted_rollback_segments.html" rel="bookmark" class="crp_title">_OFFLINE_ROLLBACK_SEGMENTS/_CORRUPTED_ROLLBACK_SEGMENTS</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/01/hgdb-rm-rf-recovery.html" rel="bookmark" class="crp_title">记录一次国产数据库被rm -rf /*删除的救援过程</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2018/04/enq-hw-contention.html" rel="bookmark" class="crp_title">数据文件自扩展引起&#8212;enq: HW &#8211; contention</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/11/windows-listener-log-4g.html" rel="bookmark" class="crp_title">windows平台listener.log超过4G导致监听异常</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/04/%e9%80%9a%e8%bf%87administration-assistant-for-windows%e9%85%8d%e7%bd%aewin%e6%9c%8d%e5%8a%a1%e5%92%8c%e5%ae%9e%e4%be%8b%e5%85%b3%e8%81%94%e6%80%a7.html" rel="bookmark" class="crp_title">通过Administration Assistant for Windows配置win服务和实例关联性</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/07/%e9%80%9a%e8%bf%87awr%e6%8c%87%e6%a0%87%e8%af%84%e4%bc%b0%e4%bc%9a%e8%af%9d%e5%bb%ba%e7%ab%8b%e6%98%af%e5%90%a6%e9%a2%91%e7%b9%81.html" rel="bookmark" class="crp_title">通过awr指标评估会话建立是否频繁</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/12/sql-bak-0-lost-data.html" rel="bookmark" class="crp_title">模拟sql server故障备份完成恢复实现数据0丢失</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/12/ufs-recovery-lvm.html" rel="bookmark" class="crp_title">linux异常磁盘lvm恢复操作演示</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/10/linux7-8-single-user.html" rel="bookmark" class="crp_title">redhat系列7/8进入单用户模式</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2016/05/result-cache-rc-latch.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
