<?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>dbAnt</title>
	<atom:link href="https://www.dbant.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbant.com/</link>
	<description>Focus on the database architecture.</description>
	<lastBuildDate>Mon, 02 Sep 2024 11:22:23 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.1</generator>

<image>
	<url>https://www.dbant.com/wp-content/uploads/2024/08/ant_2.ico</url>
	<title>dbAnt</title>
	<link>https://www.dbant.com/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>OGG报错dirtmp目录占满</title>
		<link>https://www.dbant.com/2024/09/02/ogg%e6%8a%a5%e9%94%99dirtmp%e7%9b%ae%e5%bd%95%e5%8d%a0%e6%bb%a1/</link>
		
		<dc:creator><![CDATA[dbAnt]]></dc:creator>
		<pubDate>Mon, 02 Sep 2024 11:07:55 +0000</pubDate>
				<category><![CDATA[Goldengate]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[TroubleShooting]]></category>
		<guid isPermaLink="false">https://www.dbant.com/?p=178</guid>

					<description><![CDATA[<p>【问题】 接到告警，发现extract进程ABENDED 查看进程日志如下： **************** [&#8230;]</p>
<p><a href="https://www.dbant.com/2024/09/02/ogg%e6%8a%a5%e9%94%99dirtmp%e7%9b%ae%e5%bd%95%e5%8d%a0%e6%bb%a1/">OGG报错dirtmp目录占满</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>【问题】</p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;"><span lang="zh-CN">接到告警，发现</span><span lang="en-US">extract</span><span lang="zh-CN">进程</span><span lang="en-US">ABENDED</span></p>
<p><img fetchpriority="high" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/09/f2381dadbe9c43f8806033906e5a81a5.png" width="673" height="299" /></p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;">查看进程日志如下：</p>
<blockquote><p>***********************************************************************</p>
<p>**                     Run Time Messages                             **</p>
<p>***********************************************************************</p>
<p>2024-08-25 13:22:11  INFO    OGG-01517  Position of first record processed Log Number: 79079</p>
<p>Record Offset: 67072343, Aug 24, 2024 12:32:26 AM.</p>
<p>2024-08-25 13:22:11  INFO    OGG-06507  MAP (TABLE) resolved (entry pub_credit.ent_core_data_count): TABLE &#8220;pub_credit&#8221;.&#8221;ent_core_data_</p>
<p>count&#8221;.</p>
<p>2024-08-25 13:22:11  INFO    OGG-06509  Using the following key columns for source table pub_credit.ent_core_data_count: ogg_key_id.</p>
<p>2024-08-25 13:23:25  WARNING OGG-01266  cm_mf_write_lower: write: to_write: 98304  errno: 28 (No space left on device)  co_uid: 1  /ogg</p>
<p>/dirtmp/e_ph02_p48330_extr_0x7f968d981020_00016.cm.</p>
<p>2024-08-25 13:23:25  WARNING OGG-01857  cachemgr: filecaching: cm_mf_write_upper: /ogg/dirtmp.</p>
<p>2024-08-25 13:23:25  WARNING OGG-01262  The call to the cm_mf_write_lower() function from line 3164 in cm_mf_get() failed with reason &#8216;</p>
<p>no space on directories: error: 108: co: 00007F968D981020 obj_id: &lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;37&gt;&lt;</p>
<p>39&gt;&lt;30&gt;&lt;37&gt;&lt;39&gt;&lt;3A&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;36&gt;&lt;37&gt;&lt;30&gt;&lt;37&gt;&lt;32&gt;&lt;33&gt;&lt;34&gt;&lt;33&gt;&#8217;.</p>
<p>Source Context :</p>
<p>SourceModule            : [ggapp.cmgr_filecaching]
<p>SourceID                : [/scratch/aime/adestore/views/aime_adc4150378/oggcore/OpenSys/src/gglib/ggapp/cachemgr/cmgr_filecache.c]
<p>SourceFunction          : [cm_mf_write_upper]
<p>SourceLine              : [854]
<p>ThreadBacktrace         : [6] elements</p>
<p>: [/ogg/libgglog.so(CMessageContext::AddThreadContext()+0x26) [0x7f969a2d6336]]
<p>: [/ogg/libgglog.so(CMessageFactory::CreateMessage(CSourceContext*, unsigned int, &#8230;)+0x6a8) [0x7f969a2c9358</p>
<p>]]
<p>: [/ogg/libgglog.so(_MSG_ERR_CACHEMGR_FILECACHING_FILE(CSourceContext*, char const*, CMessageFactory::Message</p>
<p>Disposition)+0x41) [0x7f969a270a41]]
<p>: [/ogg/extract(cm_filecaching_thread(void*)+0x2b49) [0x6ed689]]
<p>: [/lib64/libpthread.so.0(+0x7dd5) [0x7f96971b2dd5]]
<p>: [/lib64/libc.so.6(clone+0x6d) [0x7f969579fead]]
<p>2024-08-25 13:23:25  <span style="color: #ff0000;">ERROR   OGG-01853  cachemgr: filecaching: cm_mf_write_upper: /ogg/dirtmpcm_mf_get: no space on directories: error:</span></p>
<p>108: co: 00007F968D981020 obj_id: &lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;37&gt;&lt;39&gt;&lt;30&gt;&lt;37&gt;&lt;39&gt;&lt;3A&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;</p>
<p>&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;30&gt;&lt;36&gt;&lt;37&gt;&lt;30&gt;&lt;37&gt;&lt;32&gt;&lt;33&gt;&lt;34&gt;&lt;33&gt;.</p>
<p>***********************************************************************</p>
<p>*                   ** Run Time Statistics **                         *</p>
<p>***********************************************************************</p></blockquote>
<p>&nbsp;</p>
<p>【分析】</p>
<p>从日志看到报错，是因为空间满了：</p>
<p><span style="color: #ff0000;">ERROR   OGG-01853  cachemgr: filecaching: cm_mf_write_upper: /ogg/dirtmpcm_mf_get: no space on directories: error:</span></p>
<p><img decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/09/1da0d331cada710990e9e0054553ccaa.png" width="406" height="138" /></p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;"><span lang="zh-CN">发现</span><span lang="en-US">dirtmp</span><span lang="zh-CN">目录占了</span><span lang="en-US">32G</span><span lang="zh-CN">，这是罪魁祸首。</span></p>
<p>&nbsp;</p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;">参考：</p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;"><a href="https://docs.oracle.com/en/middleware/goldengate/core/19.1/installing/temporary-disk-requirements.html">https://docs.oracle.com/en/middleware/goldengate/core/19.1/installing/temporary-disk-requirements.html</a></p>
<p>&nbsp;</p>
<p style="margin: 0in; font-size: 12.0pt; color: #1a1816;"><span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono'; background: white;">当总缓存事务数据超过</span> <span lang="zh-CN" style="font-style: italic; font-family: 'Microsoft YaHei Mono';">CACHEMGR</span> <span lang="zh-CN" style="font-style: italic; font-family: 'Microsoft YaHei Mono';">CACHESIZE</span> <span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono'; background: white;">参数时，Extract 将开始将缓存数据写入临时文件。</span></p>
<p style="margin: 0in; font-size: 12.0pt;"><span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono'; color: #1a1816; background: white;">默认会使用整改目录的大小，建议设置一个单独专用的目录，并通过</span> <span lang="zh-CN" style="font-style: italic; font-family: 'Microsoft YaHei Mono'; color: #1a1816;">CACHEMGR</span> <span lang="zh-CN" style="font-style: italic; font-family: 'Microsoft YaHei Mono'; color: #1a1816;">CACHEDIRECTORY</span><span lang="zh-CN" style="font-style: italic; font-family: 'Microsoft YaHei Mono';"> </span><span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono'; color: #1a1816; background: white;">参数指定。</span></p>
<p>&nbsp;</p>
<p style="margin: 0in; margin-left: .375in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;"><span style="font-weight: bold; background: #FFFF99;">注意：</span></p>
<p style="margin: 0in; margin-left: .75in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;"><span style="color: #1a1816; background: white;">CACHEMGR</span> 是一个内部自动配置和自动调节的参数，Oracle 建议不要更改 CACHESIZE，因为根据环境的不同，可能会对性能产生不利影响。</p>
<p>&nbsp;</p>
<p style="margin: 0in; font-size: 12.0pt;"><span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono';">通常情况下，</span><span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono'; color: #1a1816; background: white;">操作系统写</span> <span lang="en-US" style="font-family: 'Microsoft YaHei Mono'; color: #1a1816; background: white;">swap </span><span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono'; color: #1a1816; background: white;">的效率高于写临时文件的效率。默认的</span> <span lang="zh-CN" style="font-style: italic; font-family: 'Microsoft YaHei Mono'; color: #1a1816;">CACHESIZE</span> <span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono'; color: #1a1816; background: white;">参数就是这样设定的。</span></p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt; color: #1a1816;"><span lang="zh-CN" style="background: white;">当事务提交或回滚之后，对应的临时文件也会被删除。所以这里</span><span lang="en-US" style="background: white;">dirtmp</span><span lang="zh-CN" style="background: white;">目录占用了</span><span lang="en-US" style="background: white;">32G</span><span lang="zh-CN" style="background: white;">导入整个</span><span lang="en-US" style="background: white;">/ogg</span><span lang="zh-CN" style="background: white;">目录满了，是因为这是一个大事务。</span></p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt; color: #1a1816;"><span lang="zh-CN" style="background: white;">了解发现由于上游系统有个表做了历史数据清理，导致</span><span lang="en-US" style="background: white;">OGG</span><span lang="zh-CN" style="background: white;">同步这个</span><span lang="en-US" style="background: white;">delete</span><span lang="zh-CN" style="background: white;">语句的事务很大。</span></p>
<p>&nbsp;</p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt; color: #1a1816;"><span style="background: white;">【解决】</span></p>
<p style="margin: 0in; font-size: 12.0pt;"><span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono';">临时扩容</span><span lang="en-US" style="font-family: Calibri;">/ogg </span><span lang="zh-CN" style="font-family: 'Microsoft YaHei Mono';">目录，等这个大事务执行完成之后，目录空间就自动释放了。</span></p>
<p><img decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/09/5cb220b909df49b52c59e9780a121ed9.png" width="668" height="56" /></p>
<p>&nbsp;</p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;"><span lang="en-US">OGG</span><span lang="zh-CN">同步恢复正常</span></p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/09/42e5efc6381a17d1af64bd33d89ef5ff.png" width="678" height="300" /></p>
<p>&nbsp;</p>
<p><a href="https://www.dbant.com/2024/09/02/ogg%e6%8a%a5%e9%94%99dirtmp%e7%9b%ae%e5%bd%95%e5%8d%a0%e6%bb%a1/">OGG报错dirtmp目录占满</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>基于SQL Tuning Advisor做SQL优化的方法</title>
		<link>https://www.dbant.com/2024/08/06/%e5%9f%ba%e4%ba%8esql-tuning-advisor%e5%81%9asql%e4%bc%98%e5%8c%96%e7%9a%84%e6%96%b9%e6%b3%95/</link>
		
		<dc:creator><![CDATA[dbAnt]]></dc:creator>
		<pubDate>Tue, 06 Aug 2024 02:05:03 +0000</pubDate>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<guid isPermaLink="false">http://www.dbant.com/?p=169</guid>

					<description><![CDATA[<p>【背景】 今天有同事反馈业务系统有个简单的查询SQL跑的很慢，要3秒左右，我的第一直觉就是索引问题。 下面我们 [&#8230;]</p>
<p><a href="https://www.dbant.com/2024/08/06/%e5%9f%ba%e4%ba%8esql-tuning-advisor%e5%81%9asql%e4%bc%98%e5%8c%96%e7%9a%84%e6%96%b9%e6%b3%95/">基于SQL Tuning Advisor做SQL优化的方法</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>【背景】</p>
<p>今天有同事反馈业务系统有个简单的查询SQL跑的很慢，要3秒左右，我的第一直觉就是索引问题。</p>
<p>下面我们就用这个例子，来看看怎么用 SQL Tuning Advisor 做SQL优化。</p>
<p>&nbsp;</p>
<p>【分析】</p>
<p>使用SQL Tuning Advisor 来代替人工分析，包括：</p>
<p>• 为统计信息丢失或失效的对象收集统计信息<br />
• 考虑优化器的任何数据偏差、复杂谓词或失效的统计信息<br />
• 重新构建 SQL 以优化性能<br />
• 提出新索引建议</p>
<p>&nbsp;</p>
<p>原始SQL如下：</p>
<pre class="brush: sql; title: ; notranslate">

select decode(remamt1, '', decode(remamt2, '', t3.remamt, remamt2), remamt1) remamta,
 t3.remamt remamt3,
 tt.*
 from (select t1.remamt remamt1,
 t2.remamt as remamt2,
 t1.bizid,
 t1.serseqno
 from b_wf_voumng t1
 left join bedc_detail t2
 on t1.bizid = t2.bizid) tt
 left join bedc_hisdetail t3
 on tt.bizid = t3.bizid
 where serseqno = #{serseqno}

</pre>
<p>查找SQL ID</p>
<pre class="brush: sql; title: ; notranslate">
col SQL_FULLTEXT for a100
select SQL_ID, PLAN_HASH_VALUE, SQL_FULLTEXT from v$sql where SQL_TEXT like 'select decode%bedc_detail%';
</pre>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/08/0560a96e0a2c4c6a8956089f69bcba28.png" alt="" width="842" height="250" /></p>
<p>&nbsp;</p>
<p>查看SQL执行计划</p>
<pre class="brush: sql; title: ; notranslate">
select * from table(dbms_xplan.display_cursor('aqfdvtkcrptbx'));
</pre>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/08/e1410c410e3886e433cfef7059206416.png" alt="" width="720" height="407" /></p>
<p>这里可以看到 B_WF_VOUMNG 表确实是走了全表扫描，只要加上对应的索引就好了。</p>
<p>&nbsp;</p>
<p>下面我们看看 SQL Tuning Advisor 的分析建议</p>
<p>根据SQL_ID创建优化分析任务，如果有多个执行计划，也可以指定执行计划的hash值</p>
<pre class="brush: sql; title: ; notranslate">
DECLARE
 MY_TASK_NAME VARCHAR2(1024);
BEGIN
 MY_TASK_NAME := DBMS_SQLTUNE.CREATE_TUNING_TASK(
 sql_id =&gt;; 'aqfdvtkcrptbx',
 --plan_hash_value =&gt; '2744121178',
 scope =&gt; 'COMPREHENSIVE',
 time_limit =&gt; 60,
 task_name =&gt; 'my_tuning_task',
 description =&gt; 'TUNING TASK');
END;
/
</pre>
<p>查看创建的优化任务</p>
<pre class="brush: sql; title: ; notranslate">
SELECT task_name, status FROM dba_ADVISOR_TASKS WHERE task_name ='my_tuning_task';
</pre>
<p>&nbsp;</p>
<p>执行优化任务，进行分析</p>
<pre class="brush: sql; title: ; notranslate">
EXEC DBMS_SQLTUNE.EXECUTE_TUNING_TASK('my_tuning_task');
</pre>
<p>&nbsp;</p>
<p>查看分析结果</p>
<pre class="brush: sql; title: ; notranslate">
set LONG 999999
set SERVEROUTPUT ON SIZE 999999
set LINESIZE 200
set PAGES 9999
col DBMS_SQLTUNE.REPORT_TUNING_TASK('my_tuning_task') for a200

SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK('my_tuning_task') FROM DUAL;
</pre>
<p>&nbsp;</p>
<p>【分析结果如下】<br />
分析结果比较长，分成3段看一下</p>
<p>第一段如下：</p>
<pre class="brush: sql; title: ; notranslate">
DBMS_SQLTUNE.REPORT_TUNING_TASK('MY_TUNING_TASK')
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GENERAL INFORMATION SECTION
-------------------------------------------------------------------------------
Tuning Task Name : my_tuning_task
Tuning Task Owner : SYS
Workload Type : Single SQL Statement
Scope : COMPREHENSIVE
Time Limit(seconds): 60
Completion Status : COMPLETED
Started at : 07/31/2024 14:10:31
Completed at : 07/31/2024 14:10:41

-------------------------------------------------------------------------------
Schema Name: CMS
SQL ID : aqfdvtkcrptbx
SQL Text : select decode(remamt1, '', decode(remamt2, '', t3.remamt,
 remamt2), remamt1) remamta,
 t3.remamt remamt3,
 tt.*
 from (select t1.remamt remamt1,
 t2.remamt as remamt2,
 t1.bizid,
 t1.serseqno
 from b_wf_voumng t1
 left join bedc_detail t2
 on t1.bizid = t2.bizid) tt
 left join bedc_hisdetail t3
 on tt.bizid = t3.bizid
 where serseqno = :1
Bind Variables :
 1 - (VARCHAR2(128)):SKSY24072400000833

-------------------------------------------------------------------------------
FINDINGS SECTION (3 findings)
-------------------------------------------------------------------------------

1- SQL Profile Finding (see explain plans section below)
--------------------------------------------------------
 A potentially better execution plan was found for this statement.

 Recommendation (estimated benefit: 98.26%)
 ------------------------------------------
 - Consider accepting the recommended SQL profile to use parallel execution
 for this statement.
 execute dbms_sqltune.accept_sql_profile(task_name =&amp;amp;gt; 'my_tuning_task',
 task_owner =&amp;amp;gt; 'SYS', replace =&amp;amp;gt; TRUE, profile_type =&amp;amp;gt;
 DBMS_SQLTUNE.PX_PROFILE);

 Executing this query parallel with DOP 64 will improve its response time
 98.27% over the original plan. However, there is some cost in enabling
 parallel execution. It will increase the statement's resource consumption by
 an estimated 11.03% which may result in a reduction of system throughput.
 Also, because these resources are consumed over a much smaller duration, the
 response time of concurrent statements might be negatively impacted if
 sufficient hardware capacity is not available.

 The following data shows some sampled statistics for this SQL from the past
 week and projected weekly values when parallel execution is enabled.

 Past week sampled statistics for this SQL
 -----------------------------------------
 Number of executions 0
 Percent of total activity 0
 Percent of samples with #Active Sessions &amp;amp;gt; 2*CPU 0
 Weekly DB time (in sec) 0

 Projected statistics with Parallel Execution
 --------------------------------------------
 Weekly DB time (in sec) 0
</pre>
<p>SQL Tuning Advisor 给的第一个建议是开启并发执行，可以看到预计收益达到98.26%（estimated benefit: 98.26%），<br />
效果是非常好的，但是可能会对数据库其他SQL造成影响，我们先不考虑。</p>
<p>&nbsp;</p>
<p>第二段如下：</p>
<pre class="brush: sql; title: ; notranslate">
2- Index Finding (see explain plans section below)
--------------------------------------------------
 The execution plan of this statement can be improved by creating one or more
 indices.

 Recommendation (estimated benefit: 99.99%)
 ------------------------------------------
 - Consider running the Access Advisor to improve the physical schema design
 or creating the recommended index.
 create index CMS.IDX$$_516130001 on CMS.B_WF_VOUMNG(&quot;SERSEQNO&quot;,&quot;BIZID&quot;,&quot;REM
 AMT&quot;);

 Rationale
 ---------
 Creating the recommended indices significantly improves the execution plan
 of this statement. However, it might be preferable to run &quot;Access Advisor&quot;
 using a representative SQL workload as opposed to a single statement. This
 will allow to get comprehensive index recommendations which takes into
 account index maintenance overhead and additional space consumption.
&amp;lt;/pre&amp;gt;&amp;lt;pre&amp;gt;</pre>
<p>第二个建议是添加索引，也就是我们刚开始说的，这个预估收益达到99.99%（estimated benefit: 99.99%），效果比开启并发执行还要好。</p>
<p>&nbsp;</p>
<p>再来看看第三段</p>
<pre class="brush: sql; title: ; notranslate">
3- Alternative Plan Finding
---------------------------
 Some alternative execution plans for this statement were found by searching
 the system's real-time and historical performance data.

 The following table lists these plans ranked by their average elapsed time.
 See section &quot;ALTERNATIVE PLANS SECTION&quot; for detailed information on each
 plan.

 id plan hash last seen elapsed (s) origin note
 -- ---------- -------------------- ------------ --------------- ----------------
 1 3788302452 2024-07-26/17:00:04 0.684 AWR
 2 2290443376 2024-07-31/08:39:39 5.907 Cursor Cache original plan

 Recommendation
 --------------
 - Consider creating a SQL plan baseline for the plan with the best average
 elapsed time.
 execute dbms_sqltune.create_sql_plan_baseline(task_name =&amp;amp;gt;
 'my_tuning_task', owner_name =&amp;amp;gt; 'SYS', plan_hash_value =&amp;amp;gt;
 3788302452);

-------------------------------------------------------------------------------
EXPLAIN PLANS SECTION
-------------------------------------------------------------------------------

1- Original
-----------
Plan hash value: 2290443376

---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 175 | 77663 (1)| 00:15:32 |
| 1 | NESTED LOOPS OUTER | | 1 | 175 | 77663 (1)| 00:15:32 |
| 2 | NESTED LOOPS OUTER | | 1 | 111 | 77661 (1)| 00:15:32 |
|* 3 | TABLE ACCESS FULL | B_WF_VOUMNG | 1 | 44 | 77659 (1)| 00:15:32 |
| 4 | TABLE ACCESS BY INDEX ROWID| BEDC_DETAIL | 1 | 67 | 2 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | BEDC_DETAIL_INDEX | 1 | | 1 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID | BEDC_HISDETAIL | 1 | 64 | 2 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | SYS_C00139561 | 1 | | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

 3 - filter(&quot;T1&quot;.&quot;SERSEQNO&quot;=:1)
 5 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T2&quot;.&quot;BIZID&quot;(+))
 7 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T3&quot;.&quot;BIZID&quot;(+))

2- Using New Indices
--------------------
Plan hash value: 2517111532

---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 175 | 7 (0)| 00:00:01 |
| 1 | NESTED LOOPS OUTER | | 1 | 175 | 7 (0)| 00:00:01 |
| 2 | NESTED LOOPS OUTER | | 1 | 111 | 5 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | IDX$$_516130001 | 1 | 44 | 3 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID| BEDC_DETAIL | 1 | 67 | 2 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | BEDC_DETAIL_INDEX | 1 | | 1 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID | BEDC_HISDETAIL | 1 | 64 | 2 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | SYS_C00139561 | 1 | | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

 3 - access(&quot;T1&quot;.&quot;SERSEQNO&quot;=:1)
 5 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T2&quot;.&quot;BIZID&quot;(+))
 7 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T3&quot;.&quot;BIZID&quot;(+))

3- Using Parallel Execution
---------------------------
Plan hash value: 3538277696

----------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
----------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 175 | 1347 (0)| 00:00:17 | | | |
| 1 | PX COORDINATOR | | | | | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10000 | 1 | 175 | 1347 (0)| 00:00:17 | Q1,00 | P-&amp;amp;gt;S | QC (RAND) |
| 3 | NESTED LOOPS OUTER | | 1 | 175 | 1347 (0)| 00:00:17 | Q1,00 | PCWP | |
| 4 | NESTED LOOPS OUTER | | 1 | 111 | 1347 (0)| 00:00:17 | Q1,00 | PCWP | |
| 5 | PX BLOCK ITERATOR | | | | | | Q1,00 | PCWC | |
|* 6 | TABLE ACCESS FULL | B_WF_VOUMNG | 1 | 44 | 1347 (0)| 00:00:17 | Q1,00 | PCWP | |
| 7 | TABLE ACCESS BY INDEX ROWID| BEDC_DETAIL | 1 | 67 | 0 (0)| 00:00:01 | Q1,00 | PCWP | |
|* 8 | INDEX UNIQUE SCAN | BEDC_DETAIL_INDEX | 1 | | 0 (0)| 00:00:01 | Q1,00 | PCWP | |
| 9 | TABLE ACCESS BY INDEX ROWID | BEDC_HISDETAIL | 1 | 64 | 0 (0)| 00:00:01 | Q1,00 | PCWP | |
|* 10 | INDEX UNIQUE SCAN | SYS_C00139561 | 1 | | 0 (0)| 00:00:01 | Q1,00 | PCWP | |
----------------------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

 6 - filter(&quot;T1&quot;.&quot;SERSEQNO&quot;=:1)
 8 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T2&quot;.&quot;BIZID&quot;(+))
 10 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T3&quot;.&quot;BIZID&quot;(+))

-------------------------------------------------------------------------------
ALTERNATIVE PLANS SECTION
-------------------------------------------------------------------------------

Plan 2
------

 Plan Origin :Cursor Cache
 Plan Hash Value :2290443376
 Executions :10777
 Elapsed Time :5.907 sec
 CPU Time :0.723 sec
 Buffer Gets :263726
 Disk Reads :263668
 Disk Writes :0

Notes:
 1. Statistics shown are averaged over multiple executions.
 2. The plan matches the original plan.

---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 175 | 77663 (1)| 00:15:32 |
| 1 | NESTED LOOPS OUTER | | 1 | 175 | 77663 (1)| 00:15:32 |
| 2 | NESTED LOOPS OUTER | | 1 | 111 | 77661 (1)| 00:15:32 |
|* 3 | TABLE ACCESS FULL | B_WF_VOUMNG | 1 | 44 | 77659 (1)| 00:15:32 |
| 4 | TABLE ACCESS BY INDEX ROWID| BEDC_DETAIL | 1 | 67 | 2 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | BEDC_DETAIL_INDEX | 1 | | 1 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID | BEDC_HISDETAIL | 1 | 64 | 2 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | SYS_C00139561 | 1 | | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

 3 - filter(&quot;T1&quot;.&quot;SERSEQNO&quot;=:1)
 5 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T2&quot;.&quot;BIZID&quot;(+))
 7 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T3&quot;.&quot;BIZID&quot;(+))

Plan 1
------

 Plan Origin :AWR
 Plan Hash Value :3788302452
 Executions :5764
 Elapsed Time :0.684 sec
 CPU Time :0.678 sec
 Buffer Gets :71476
 Disk Reads :0
 Disk Writes :0

Notes:
 1. Statistics shown are averaged over multiple executions.

---------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 175 | 81836 (1)| 00:16:23 |
| 1 | NESTED LOOPS OUTER | | 1 | 175 | 81836 (1)| 00:16:23 |
| 2 | NESTED LOOPS OUTER | | 1 | 111 | 81834 (1)| 00:16:23 |
| 3 | TABLE ACCESS BY INDEX ROWID| B_WF_VOUMNG | 1 | 44 | 81832 (1)| 00:16:22 |
|* 4 | INDEX SKIP SCAN | B_WF_VOUMNG_IDX7 | 1 | | 81830 (1)| 00:16:22 |
| 5 | TABLE ACCESS BY INDEX ROWID| BEDC_DETAIL | 1 | 67 | 2 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | BEDC_DETAIL_INDEX | 1 | | 1 (0)| 00:00:01 |
| 7 | TABLE ACCESS BY INDEX ROWID | BEDC_HISDETAIL | 1 | 64 | 2 (0)| 00:00:01 |
|* 8 | INDEX UNIQUE SCAN | SYS_C00139561 | 1 | | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

 4 - access(&quot;T1&quot;.&quot;SERSEQNO&quot;=:1)
 filter(&quot;T1&quot;.&quot;SERSEQNO&quot;=:1)
 6 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T2&quot;.&quot;BIZID&quot;(+))
 8 - access(&quot;T1&quot;.&quot;BIZID&quot;=&quot;T3&quot;.&quot;BIZID&quot;(+))

-------------------------------------------------------------------------------
</pre>
<p>这一段主要是列出各个建议的执行计划情况，包括原始执行计划、添加了索引的执行计划、并发执行的执行计划等等， 这里我们可以看到添加索引的执行计划（2- Using New Indices）的成本是最低的，也是最优的。</p>
<p>&nbsp;</p>
<p>最后，删除刚刚创建的 SQL Tuning Advisor 任务</p>
<pre class="brush: sql; title: ; notranslate">
EXEC dbms_sqltune.drop_tuning_task('my_tuning_task');
</pre>
<p>&nbsp;</p>
<p>【解决】</p>
<p>最后我们只要根据建议加上索引就可以了。</p>
<pre class="brush: sql; title: ; notranslate">
create index CMS.IDX$$_516130001 on CMS.B_WF_VOUMNG(&quot;SERSEQNO&quot;,&quot;BIZID&quot;,&quot;REM AMT&quot;);
</pre>
<p>查看索引</p>
<pre class="brush: sql; title: ; notranslate">
col COLUMN_NAME for a20
SELECT TABLE_OWNER,
 TABLE_NAME,
 INDEX_NAME,
 COLUMN_NAME,
 COLUMN_POSITION
FROM dba_ind_columns
WHERE table_name='B_WF_VOUMNG'
order by INDEX_NAME,COLUMN_POSITION;
</pre>
<p>【参考】</p>
<p>Using the DBMS_SQLTUNE Package to Run the SQL Tuning Advisor (Doc ID 262687.1)</p>
<p><a href="https://www.dbant.com/2024/08/06/%e5%9f%ba%e4%ba%8esql-tuning-advisor%e5%81%9asql%e4%bc%98%e5%8c%96%e7%9a%84%e6%96%b9%e6%b3%95/">基于SQL Tuning Advisor做SQL优化的方法</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ORA-04030: out of process memory when trying to allocate 432 bytes (kxs-heap-c,kprbalo temp memory)</title>
		<link>https://www.dbant.com/2024/07/08/ora-04030-out-of-process-memory/</link>
		
		<dc:creator><![CDATA[dbAnt]]></dc:creator>
		<pubDate>Mon, 08 Jul 2024 10:49:17 +0000</pubDate>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[TroubleShooting]]></category>
		<guid isPermaLink="false">http://www.dbant.com/?p=142</guid>

					<description><![CDATA[<p>&#160; 【报错】 接到告警电话，查看alert 日志报错如下： Thu Jun 20 22:17:11  [&#8230;]</p>
<p><a href="https://www.dbant.com/2024/07/08/ora-04030-out-of-process-memory/">ORA-04030: out of process memory when trying to allocate 432 bytes (kxs-heap-c,kprbalo temp memory)</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<h2>【报错】</h2>
<p>接到告警电话，查看alert 日志报错如下：</p>
<blockquote><p>Thu Jun 20 22:17:11 2024</p>
<p>Errors in file /oracle/diag/rdbms/coredb/coredb/trace/coredb_j003_23800.trc  (incident=288071):</p>
<p><b>ORA-04030</b>: out of process memory when trying to allocate 432 bytes (<span style="color: #ff0000;">kxs-heap-c,kprbalo temp memory</span>)</p>
<p>Use ADRCI or Support Workbench to package the incident.</p>
<p>See Note 411.1 at My Oracle Support for error and packaging details.</p>
<p>End automatic SQL Tuning Advisor run for special tuning task  &#8220;SYS_AUTO_SQL_TUNING_TASK&#8221;</p>
<p>Thu Jun 20 22:17:13 2024</p>
<p>Sweep [inc][288071]: completed</p></blockquote>
<pre></pre>
<p>&nbsp;</p>
<h2>【分析】</h2>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/f8f144e80deb5b67004ec479d47938ba.png" alt="" width="864" height="90" /></p>
<p>当操作系统请求内存或其他资源，而系统资源不足时，就会报错 ORA-4030，这里我们可以看到 <span style="color: #ff0000;">kxs-heap-c,kprbalo temp memory</span> 是内存的问题，也就是<span style="color: #ff0000;">PGA内存不足</span>了。</p>
<p>&nbsp;</p>
<p>1、如果 ORA-4030 报错没有对应的trace详细信息，可以手动开启</p>
<pre class="brush: sql; title: ; notranslate">

## 开启trace

ALTER SYSTEM SET EVENTS '4030 trace name heapdump level 536870917;name errorstack level 3';

## 等ORA-4030错误再次出现之后，关闭trace

ALTER SYSTEM SET EVENTS '4030 trace name context off; name context off';

</pre>
<p>&nbsp;</p>
<p>2、查看trace文件：/oracle/diag/rdbms/coredb/coredb/trace/coredb_j003_23800.trc</p>
<blockquote><p><span style="color: #000000;"><em>*** 2024-06-20 22:00:04.116</em></span></p>
<p><span style="color: #000000;"><em>*** SESSION ID:(406.2663) 2024-06-20 22:00:04.116</em></span></p>
<p><span style="color: #000000;"><em>*** CLIENT ID:() 2024-06-20 22:00:04.116</em></span></p>
<p><span style="color: #000000;"><em>*** SERVICE NAME:(SYS$USERS) 2024-06-20 22:00:04.116</em></span></p>
<p><span style="color: #000000;"><em>*** MODULE NAME:(DBMS_SCHEDULER) 2024-06-20 22:00:04.116</em></span></p>
<p><span style="color: #000000;"><em>*** <span style="color: #ff0000;">ACTION NAME:(ORA$AT_SQ_SQL_SW_3355)</span> 2024-06-20 22:00:04.116</em></span></p>
<p>&nbsp;</p>
<p><span style="color: #000000;"><em>status=(pst=ERROR)</em></span></p>
<p><span style="color: #000000;"><em>status=(pst=ERROR)</em></span></p>
<p><span style="color: #000000;"><em>status=(pst=ERROR)</em></span></p>
<p><span style="color: #000000;"><em>&#8230;</em></span></p>
<p><span style="color: #000000;"><em>Incident 273219 created, dump file: /oracle/diag/rdbms/coredb/coredb/incident/incdir_273219/coredb_j003_23800_i273219.trc</em></span></p>
<p><span style="color: #000000;"><em>ORA-04030: out of process memory when trying to allocate 432 bytes (<span style="color: #ff0000;">kxs-heap-c,kprbalo temp memory</span>)</em></span></p>
<p>&nbsp;</p>
<p><span style="color: #000000;"><em>Incident 273220 created, dump file: /oracle/diag/rdbms/coredb/coredb/incident/incdir_273220/coredb_j003_23800_i273220.trc</em></span></p>
<p><span style="color: #000000;"><em>ORA-04030: out of process memory when trying to allocate 169040 bytes (<span style="color: #ff0000;">pga heap,kgh stack</span>)</em></span></p>
<p><span style="color: #000000;"><em>ORA-04030: out of process memory when trying to allocate 432 bytes (kxs-heap-c,kprbalo temp memory)</em></span></p>
<p>&nbsp;</p>
<p><span style="color: #000000;"><em>Incident 273221 created, dump file: /oracle/diag/rdbms/coredb/coredb/incident/incdir_273221/coredb_j003_23800_i273221.trc</em></span></p>
<p><span style="color: #000000;"><em>ORA-04030: out of process memory when trying to allocate 82456 bytes (<span style="color: #ff0000;">pga heap,control file i/o buffer</span>)</em></span></p>
<p><span style="color: #000000;"><em>ORA-04030: out of process memory when trying to allocate 432 bytes (kxs-heap-c,kprbalo temp memory)</em></span></p></blockquote>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/17b948ee364ac9f17def126371e3e1d7.png" alt="" width="845" height="504" /></p>
<p>从上面的日志可以看到是DBMS_SCHEDULER 定时任务调用的 <span style="color: #ff0000;">ORA$AT_SQ_SQL_SW_3355</span> 模块导致 4030 报错，这个是Oracle定时执行的Automatic SQL Tuning job。</p>
<p>&nbsp;</p>
<p>## 查看trace文件：/oracle/diag/rdbms/coredb/coredb/incident/incdir_273219/coredb_j003_23800_<span style="color: #ff0000;">i273219</span>.trc</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/0dfc9c9e5f32f79dd1de10fea185b2d1.png" alt="" width="636" height="343" /></p>
<p>这里可以看到 pid 145 这个进程执行了一个存储过程占用了90%的内存。</p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/a7719c9aae308845c1d9017cc3778b2b.png" alt="" width="705" height="351" /></p>
<p>查看pid 145的详细信息，确实是<span style="color: #ff0000;">ORA$AT_SQ_SQL_SW_3355</span> 模块。</p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/04564518c62a66dd6fa8e8209055b5e3.png" alt="" width="571" height="105" /></p>
<p>这里可以看到32G的内存，剩下232M 可用，基本消耗完了。</p>
<p>&nbsp;</p>
<p>到这里，我们已经确认是Oracle每天晚上定时执行的 Automatic SQL Tuning job 导致内存耗尽的，可以选择关闭定时任务解决问题。</p>
<pre class="brush: sql; title: ; notranslate">
## 关闭job
BEGIN
dbms_auto_task_admin.disable(
client_name =&gt; 'sql tuning advisor',
operation =&gt; NULL,
window_name =&gt; NULL);
END;
/
</pre>
<p>&nbsp;</p>
<p>3、如果不想关闭这个定时任务，进一步分析日志</p>
<p>从上面的trace日志可以看到，还有另外两个错误提示：</p>
<p><span style="color: #ff0000;">(pga heap,kgh stack)</span></p>
<p><span style="color: #ff0000;">(pga heap,control file i/o buffer)</span></p>
<p>&nbsp;</p>
<p>参考MOS文档：</p>
<p>PLSQL Procedure Causing ORA-04030: (pga heap,control file i/o buffer) And ORA-04030: (koh-kghu sessi,pmuccst: adt/record) or ORA-04030: (koh-kghucall ,pmucalm coll) Errors (Doc ID 1325100.1)</p>
<p><strong>该文章提到即使PGA已经设置大于4GB，当一个进程使用内存达到4GB，就会报这个错误。</strong></p>
<p>&nbsp;</p>
<p>## 查看trace文件：/oracle/diag/rdbms/coredb/coredb/incident/incdir_273221/coredb_j003_23800_i273221.trc</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/4e081239f82e6159b2f0a212fadda174.png" alt="" width="787" height="266" /></p>
<p>可以看到trace日志中，确实内存使用达到4GB就被限制了。</p>
<p>&nbsp;</p>
<p><strong>为什么会有4GB这个限制呢？</strong></p>
<p>&nbsp;</p>
<p>## 查看trace文件的 Process Map Dump，内存dump信息</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/c90c342b8d25f4bc80f3e528756843cc.png" alt="" width="902" height="125" /></p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/95c4bd152e264a48c9660df718ec803a.png" alt="" width="901" height="111" /></p>
<p>从日志看出，进程的内存map记录数是 70986-5453+1=65534 条。</p>
<p>查看系统最大内存记录数65530（默认应该是65536），上面那个进程的记录数已经超过系统限制了</p>
<p><span style="color: #ff0000;">more /proc/sys/vm/max_map_count</span></p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/1d74568a52e53111ca836972485d3dc6.png" alt="" width="670" height="42" /></p>
<p>默认的内存分配器（realfree allocator）页大小是64KB（65536），所以64K 条记录 64KB * 64K 就是4GB，所以单进程使用达到4GB内存的限制，就报错了。</p>
<p>&nbsp;</p>
<h2>【解决】</h2>
<p>我们可以从系统层面 或 数据库层面修改这个限制。</p>
<ul>
<li>操作系统修改内存最大记录数为256K（262144），即 64KB * 256K = 16GB</li>
</ul>
<pre class="brush: sql; title: ; notranslate">

more /proc/sys/vm/max_map_count

## 临时生效

sysctl -w vm.max_map_count=262144

## 永久生效

echo &quot;vm.max_map_count=262144&quot; &amp;amp;amp;gt;&amp;amp;amp;gt; /etc/sysctl.conf

sysctl -p

</pre>
<ul>
<li>数据库修改内存分配器的页大小256KB（262144），即256KB * 64K = 16GB</li>
</ul>
<pre class="brush: sql; title: ; notranslate">

## 11.2.0.4 及以下版本:

_use_realfree_heap=TRUE

_realfree_heap_pagesize_hint = 262144

## 12.1 及以上版本:

_use_realfree_heap=TRUE

_realfree_heap_pagesize = 262144

</pre>
<p><strong>对于多租户数据库，只要修改CDB的参数即可，PDB会继承该参数。</strong></p>
<p>&nbsp;</p>
<p><strong><em><span style="color: #ff0000;">注意：</span></em></strong></p>
<p><em><span style="color: #ff0000;">请修改OS 或 DB 其中一个即可</span>，因为一个修改的是记录数，一个修改的是页大小，如果同时修改，那么限制就是 256KB * 256K = 64GB了。</em></p>
<p>&nbsp;</p>
<h2>【其他】</h2>
<p>参考文档：FAQ: ORA-4030 (Doc ID 399497.1)</p>
<p>该案例只是其中一种情况，导致  ORA-4030 的原因很多，典型的原因有：</p>
<ul>
<li>系统内存或swap空间达到限制；</li>
<li>系统达到内核或用户shell等限制，限制用户级或进程级的内存使用；</li>
<li>系统内存地址限制（32位系统），SGA占用了所有地址，导致PGA无法分配地址；</li>
<li>触发内部未公开的Bug:3130972</li>
<li>应用设计问题导致限制；</li>
<li>内存空间溢出或内存堆溢出等bug</li>
</ul>
<p>&nbsp;</p>
<p>Diagnostic Tools Catalog (Doc ID 559339.1)</p>
<p>MOS上面有很多诊断工具</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/50e480657ec8af756186d4c6644b168e.png" alt="" width="921" height="311" /></p>
<p>&nbsp;</p>
<p>可以使用 ORA-4030-Troubleshooting Tool</p>
<p>## 新建一个issue</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/3682b3d26fe8ed88941f2a860bde92ab.png" alt="" width="686" height="194" /></p>
<p>&nbsp;</p>
<p>## 支持上次TFA、IPS、RDA 3种工具收集的日志，选择其一上传即可</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/c55232b4ad3fa33e5afcab4bd64e7f6d.png" alt="" width="929" height="416" /></p>
<p>## 上传之后，如果是一个有已知问题，会给出现象、原因以及解决方案。如果是一个未知的问题，会给出相关文档以及内存监控工具，便于继续分析或提交SR。</p>
<p>&nbsp;</p>
<p>也可以使用RDA工具检查系统配置，内存使用情况等</p>
<p>./rda.sh T hcve</p>
<p>## 检查修复检查结果为 FAILED 的</p>
<p><img loading="lazy" decoding="async" class="" src="https://www.dbant.com/wp-content/uploads/2024/07/b8e23385b2b0f892932dc615f087757e.png" alt="" width="842" height="702" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2 style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;">参考：</h2>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;">Primary Note for Diagnosing OS Memory Problems and ORA-4030 (Doc ID 1088267.1)</p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;">FAQ: ORA-4030 (Doc ID 399497.1)</p>
<p style="margin: 0in; font-family: 'Microsoft YaHei Mono'; font-size: 12.0pt;"><a href="https://community.oracle.com/mosc/discussion/3900920/ora-04030-out-of-process-memory-when-trying-to-allocate-x-bytes-kxs-heap-c-kprbalo-temp-memory">https://community.oracle.com/mosc/discussion/3900920/ora-04030-out-of-process-memory-when-trying-to-allocate-x-bytes-kxs-heap-c-kprbalo-temp-memory</a></p>
<p><a href="https://www.dbant.com/2024/07/08/ora-04030-out-of-process-memory/">ORA-04030: out of process memory when trying to allocate 432 bytes (kxs-heap-c,kprbalo temp memory)</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>中科院国家授时中心NTP服务器</title>
		<link>https://www.dbant.com/2020/06/10/%e4%b8%ad%e7%a7%91%e9%99%a2%e5%9b%bd%e5%ae%b6%e6%8e%88%e6%97%b6%e4%b8%ad%e5%bf%83ntp%e6%9c%8d%e5%8a%a1%e5%99%a8/</link>
		
		<dc:creator><![CDATA[dbAnt]]></dc:creator>
		<pubDate>Wed, 10 Jun 2020 03:52:49 +0000</pubDate>
				<category><![CDATA[杂谈]]></category>
		<guid isPermaLink="false">http://www.dbant.com/?p=132</guid>

					<description><![CDATA[<p>公司的域服务器是跟一个大学的NTP做时间同步的，发现跟北京时间差了40多秒，于是网上找了很久，都是给了国家授时 [&#8230;]</p>
<p><a href="https://www.dbant.com/2020/06/10/%e4%b8%ad%e7%a7%91%e9%99%a2%e5%9b%bd%e5%ae%b6%e6%8e%88%e6%97%b6%e4%b8%ad%e5%bf%83ntp%e6%9c%8d%e5%8a%a1%e5%99%a8/">中科院国家授时中心NTP服务器</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>公司的域服务器是跟一个大学的NTP做时间同步的，发现跟北京时间差了40多秒，于是网上找了很久，都是给了国家授时中心旧的IP地址，这里就不给出来了，以免大家混淆。</p>
<p>最后在中科院的网站找到了国家授时中心的NTP域名：<em><strong> ntp.ntsc.ac.cn </strong></em></p>
<h4></h4>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>原公告地址：</p>
<p>http://www.cas.cn/tz/201809/t20180921_4664344.shtml</p>
<p>&nbsp;</p>
<p><a href="https://www.dbant.com/2020/06/10/%e4%b8%ad%e7%a7%91%e9%99%a2%e5%9b%bd%e5%ae%b6%e6%8e%88%e6%97%b6%e4%b8%ad%e5%bf%83ntp%e6%9c%8d%e5%8a%a1%e5%99%a8/">中科院国家授时中心NTP服务器</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Unique constraint &#038; Unique index in Oracle 11gR2</title>
		<link>https://www.dbant.com/2017/07/30/unique-constraint-unique-index-in-oracle-11gr2/</link>
		
		<dc:creator><![CDATA[dbAnt]]></dc:creator>
		<pubDate>Sun, 30 Jul 2017 05:25:14 +0000</pubDate>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[Oracle]]></category>
		<guid isPermaLink="false">http://www.dbant.com/?p=118</guid>

					<description><![CDATA[<p>今天探索一下唯一性约束和唯一索引的关系，我们先抛出问题，这两者的效果是否一致的呢？ 官方文档的解释： Uniq [&#8230;]</p>
<p><a href="https://www.dbant.com/2017/07/30/unique-constraint-unique-index-in-oracle-11gr2/">Unique constraint &#038; Unique index in Oracle 11gR2</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>今天探索一下唯一性约束和唯一索引的关系，我们先抛出问题，这两者的效果是否一致的呢？</p>
<p>官方文档的解释：</p>
<h3 id="autoId5" class="sect2">Unique Constraints</h3>
<p><a id="sthref626" name="sthref626"></a><a id="sthref627" name="sthref627"></a><a id="sthref628" name="sthref628"></a>A <span class="bold">unique key constraint</span> requires that every value in a column or set of columns be unique. No rows of a table may have duplicate values in a column (the<span class="bold">unique key</span>) or set of columns (the <span class="bold">composite unique key</span>) with a unique key constraint.</p>
<p class="notep1">Note:</p>
<p>The term <span class="bold">key</span> refers only to the columns defined in the integrity constraint. Because the database enforces a unique constraint by implicitly creating or reusing an <a href="glossary.htm#i432409"><span class="xrefglossterm">index</span></a> on the key columns, the term <span class="bold">unique key</span> is sometimes incorrectly used as a synonym for <span class="bold">unique key constraint</span> or <span class="bold">unique index</span>.</p>
<p>&nbsp;</p>
<h3 id="autoId4" class="sect3">Unique and Nonunique Indexes</h3>
<p><a id="sthref293" name="sthref293"></a><a id="sthref294" name="sthref294"></a><a id="sthref295" name="sthref295"></a><a id="sthref296" name="sthref296"></a>Indexes can be <span class="bold">unique</span> or nonunique. Unique indexes guarantee that no two rows of a table have duplicate values in the key column or column. For example, no two employees can have the same employee ID. Thus, in a unique index, one <a id="sthref297" name="sthref297"></a><a href="glossary.htm#CHDEFIHG">rowid</a> exists for each data value. The data in the leaf blocks is sorted only by key.</p>
<p>Nonunique indexes permit duplicates values in the indexed column or columns. For example, the <em>first_name </em>column of the <em>employees </em>table may contain multiple <em>Mike </em>values. For a nonunique index, the rowid is included in the key in sorted order, so nonunique indexes are sorted by the index key and rowid (ascending).</p>
<p>Oracle Database does not index table rows in which all key columns are <a id="sthref298" name="sthref298"></a><a href="glossary.htm#i432506"><span class="xrefglossterm">null</span></a>, except for bitmap indexes or when the cluster key column value is null.</p>
<p>&nbsp;</p>
<h3>【实验】</h3>
<p>创建表T1并添加唯一性约束：</p>
<pre class="brush: sql; title: ; notranslate">

create table t1 (
id varchar2(20),
name varchar2(30),
constraints t1_id_uk unique(id));

</pre>
<p>创建表T2并创建唯一索引：</p>
<pre class="brush: sql; title: ; notranslate">

create table t2 (
id varchar2(20),
name varchar2(30));

create unique index ind_t2_id on t2(id);

</pre>
<p>查看两个表的索引，发现T1表自动创建了唯一索引：</p>
<pre class="brush: sql; title: ; notranslate">

select OWNER,TABLE_NAME,INDEX_NAME,INDEX_TYPE,UNIQUENESS from dba_indexes where table_name in ('T1','T2');

TABLE_NAME     INDEX_NAME    INDEX_TYPE      UNIQUENES
-------------- ------------- --------------- ---------
T1             T1_ID_UK      NORMAL          UNIQUE
T2             IND_T1_ID     NORMAL          UNIQUE

</pre>
<p>索引列也是ID列</p>
<pre class="brush: sql; title: ; notranslate">
select TABLE_OWNER,TABLE_NAME,INDEX_NAME,COLUMN_NAME,COLUMN_POSITION from dba_ind_columns where table_name in ('T1','T2');

TABLE_NAME      INDEX_NAME      COLUMN_NAME     COLUMN_POSITION
--------------- --------------- --------------- ---------------
T1              T1_ID_UK        ID                            1
T2              IND_T1_ID       ID                            1

</pre>
<p>检查两个表的约束，只有T1表存在唯一性约束：</p>
<pre class="brush: sql; title: ; notranslate">
select OWNER, TABLE_NAME, CONSTRAINT_NAME, CONSTRAINT_TYPE, STATUS from dba_constraints where table_name in ('T1','T2');

TABLE_NAME      CONSTRAINT_NAME      C STATUS
--------------- -------------------- - --------
T1              T1_ID_UK             U ENABLED

</pre>
<p>T1表插入数据：</p>
<pre class="brush: sql; title: ; notranslate">

insert into t1 values('A0001','TOM');
insert into t1 values('A0001','JACK');
commit;

kamner@TESTDB&gt; insert into t1 values('A0001','JACK');
insert into t1 values('A0001','JACK')
*
ERROR at line 1:
&lt;strong&gt;ORA-00001: unique constraint (KAMNER.T1_ID_UK) violated&lt;/strong&gt;

</pre>
<p>T2表出入数据</p>
<pre class="brush: sql; title: ; notranslate">

insert into t2 values('A0001','TOM');
insert into t2 values('A0001','JACK');
commit;

kamner@TESTDB&gt; insert into t2 values('A0001','JACK');
insert into t2 values('A0001','JACK')
*
ERROR at line 1:
&lt;strong&gt;ORA-00001: unique constraint (KAMNER.IND_T1_ID) violated&lt;/strong&gt;

</pre>
<p>可以看到，T1、T2表都报唯一性约束冲突的错误。</p>
<p>接着，我们插入NULL值。</p>
<pre class="brush: sql; title: ; notranslate">

kamner@TESTDB&gt; insert into t1 values(null,'SCOTT');
1 row created.

kamner@TESTDB&gt; commit;
Commit complete.

kamner@TESTDB&gt; select * from t1;

ID                   NAME
-------------------- ------------------------------
A0001                TOM
                     SCOTT

kamner@TESTDB&gt; insert into t1 values(null,'SCOTT');
1 row created.

kamner@TESTDB&gt; insert into t1 values(null,'SCOTT');
1 row created.

kamner@TESTDB&gt; commit;
Commit complete.

kamner@TESTDB&gt; select * from t1;

ID                   NAME
-------------------- ------------------------------
A0001                TOM
                     SCOTT
                     SCOTT
                     SCOTT

</pre>
<p>我们看到，在Oracle中，每个NULL值都是不同的，因此他不受唯一索引的约束。这里给我们一点启发，在实际引用中，对于有唯一性要求的列，一般要同时添加非空约束。</p>
<p>综上，可以看出对一个表<strong>建唯一性约束和唯一索引的效果是一样的</strong>，而且可以看到，唯一性约束是通过唯一性索引来实现的。对于NULL值的情况，由于索引不会对NULL建索引页，因此更准确的说是在Oracle中，数据库没办法对NULL值进行比较，因此<strong>每个NULL值都看成是不一样的值</strong>。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="https://www.dbant.com/2017/07/30/unique-constraint-unique-index-in-oracle-11gr2/">Unique constraint &#038; Unique index in Oracle 11gR2</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>EXP-00091: Exporting questionable statistics</title>
		<link>https://www.dbant.com/2016/08/24/exp-00091-exporting-questionable-statistics/</link>
		
		<dc:creator><![CDATA[dbAnt]]></dc:creator>
		<pubDate>Wed, 24 Aug 2016 03:34:49 +0000</pubDate>
				<category><![CDATA[EXPDP/IMPDP]]></category>
		<category><![CDATA[TroubleShooting]]></category>
		<guid isPermaLink="false">http://www.dbant.com/?p=110</guid>

					<description><![CDATA[<p>最近用exp导出数据的时候报了很多EXP-00091: Exporting questionable stat [&#8230;]</p>
<p><a href="https://www.dbant.com/2016/08/24/exp-00091-exporting-questionable-statistics/">EXP-00091: Exporting questionable statistics</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>最近用exp导出数据的时候报了很多EXP-00091: Exporting questionable statistics的错误。</p>
<p>【问题现象】</p>
<pre class="brush: sql; title: ; notranslate">

exp system/123456 OWNER=rs2 file=20160823_rs2_17_8.dmp log=20160823_rs2_17_8.log

...

EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
. . exporting table ACCEPT_DETAILS 70239 rows exported
EXP-00091: Exporting questionable statistics.
&quot;20160823_rs2_17_8.log&quot; 5686L, 314896C 1,0-1 é¡¶ç«EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.
. . exporting table ACCEPT_DETAILS0527 64422 rows exported

...

</pre>
<p>&nbsp;</p>
<p>【问题处理】</p>
<p>由于exp工具会依赖与操作系统的字符串编码，所以需要将NLS_LANG环境变量设置与数据库一致。</p>
<pre class="brush: sql; title: ; notranslate">

SQL&gt; select * from nls_database_parameters;

PARAMETER                      VALUE
------------------------------ ------------------------------
NLS_LANGUAGE                   AMERICAN
NLS_TERRITORY                  AMERICA
NLS_CURRENCY                   $
NLS_ISO_CURRENCY               AMERICA
NLS_NUMERIC_CHARACTERS         .,
NLS_CHARACTERSET               ZHS16GBK
NLS_CALENDAR                   GREGORIAN
NLS_DATE_FORMAT                DD-MON-RR
NLS_DATE_LANGUAGE              AMERICAN
NLS_SORT                       BINARY
NLS_TIME_FORMAT                HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY              $
NLS_COMP                       BINARY
NLS_LENGTH_SEMANTICS           BYTE
NLS_NCHAR_CONV_EXCP            FALSE
NLS_NCHAR_CHARACTERSET         AL16UTF16
NLS_RDBMS_VERSION              10.2.0.4.0

20 rows selected.

</pre>
<p>设置Linux的NLS_LANG环境变量：</p>
<pre class="brush: sql; title: ; notranslate">
&#x5B;oracle@mfs ~]$ export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
</pre>
<p>设置windows的NLS_LANG环境变量：</p>
<pre class="brush: sql; title: ; notranslate">
C:\Users\Administrator&gt;set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
</pre>
<p>设置了环境变量之后，重新导出一切正常。</p>
<p>不过还是建议使用数据泵来导数，因为数据泵不会收到操作系统的字符集编码的影响，就不会有这样的报错了。</p>
<p><a href="https://www.dbant.com/2016/08/24/exp-00091-exporting-questionable-statistics/">EXP-00091: Exporting questionable statistics</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Indexes Are Not Dropped When Primary Key Are Dropped</title>
		<link>https://www.dbant.com/2016/07/18/indexes-are-not-dropped-when-primary-key-are-dropped/</link>
		
		<dc:creator><![CDATA[dbAnt]]></dc:creator>
		<pubDate>Mon, 18 Jul 2016 03:58:45 +0000</pubDate>
				<category><![CDATA[TroubleShooting]]></category>
		<guid isPermaLink="false">http://www.dbant.com/?p=93</guid>

					<description><![CDATA[<p>前两天遇到一个问题，在删除一个主键的之后，插入重复的数据报错ORA-00001唯一性约束冲突 test@TES [&#8230;]</p>
<p><a href="https://www.dbant.com/2016/07/18/indexes-are-not-dropped-when-primary-key-are-dropped/">Indexes Are Not Dropped When Primary Key Are Dropped</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>前两天遇到一个问题，在删除一个主键的之后，插入重复的数据报错ORA-00001唯一性约束冲突</p>
<pre class="brush: sql; title: ; notranslate">
test@TESTDB&gt; insert into t1 select * from dba_objects where rownum &lt; 100;
insert into t1 select * from dba_objects where rownum &lt; 100
*
ERROR at line 1:
ORA-00001: unique constraint (TEST.PK_T1_OBJECT_ID) violated
</pre>
<p>查询T1表主键及索引，发现主键索引仍然存在</p>
<pre class="brush: sql; title: ; notranslate">
test@TESTDB&gt; select * from dba_cons_columns where table_name='T1';

no rows selected

test@TESTDB&gt; select INDEX_OWNER,INDEX_NAME,TABLE_NAME,COLUMN_NAME from dba_ind_columns where table_name='T1';

INDEX_OWNER                    INDEX_NAME                     TABLE_NAME                     COLUMN_NAME
------------------------------ ------------------------------ ------------------------------ --------------------
TEST                           PK_T1_OBJECT_ID                T1                             OBJECT_ID
</pre>
<p>手动删除该索引，插入数据成功</p>
<pre class="brush: sql; title: ; notranslate">
test@TESTDB&gt; drop index test.PK_T1_OBJECT_ID;

Index dropped.

test@TESTDB&gt; insert into t1 select * from dba_objects where rownum &lt; 100; 

99 rows created.
</pre>
<p>正常情况下删掉主键的时候会同时删除主键附带的索引，这里为什么会出现不删除的情况呢？</p>
<p>在MOS上面有一篇文章解答了这个疑问：</p>
<p><strong>Indexes Associated With Primary Key Constraints Of Imported Tables Are Not Dropped When Constraints Are Disabled (文档 ID 887208.1)</strong></p>
<p>&nbsp;</p>
<p>由于T1表是imp导入的，而在import的时候，oracle会先创建唯一性索引，然后在添加主键约束，这就导致在创建主键的时候，唯一索引已经存在，并被主键使用，而对于并非主键创建的唯一性索引，在删除主键的时候，索引是会保留的。</p>
<p>如果想解决该问题，可以通过如下的方法进行修复：</p>
<pre class="brush: sql; title: ; notranslate">
test@TESTDB&gt; alter table t1 enable constraint PK_T1_OBJECT_ID;

Table altered.

test@TESTDB&gt;
test@TESTDB&gt; select * from dba_cons_columns where table_name='T1';

OWNER CONSTRAINT_NAME TABLE_NAME COLUMN_NAME POSITION
------------------------------ ------------------------------ ------------------------------ -------------------- ----------
TEST PK_T1_OBJECT_ID T1 OBJECT_ID 1

test@TESTDB&gt;
test@TESTDB&gt; select INDEX_OWNER,INDEX_NAME,TABLE_NAME,COLUMN_NAME from dba_ind_columns where table_name='T1';

INDEX_OWNER INDEX_NAME TABLE_NAME COLUMN_NAME
------------------------------ ------------------------------ ------------------------------ --------------------
TEST PK_T1_OBJECT_ID T1 OBJECT_ID
</pre>
<p><audio style="display: none;" controls="controls"></audio></p>
<p><a href="https://www.dbant.com/2016/07/18/indexes-are-not-dropped-when-primary-key-are-dropped/">Indexes Are Not Dropped When Primary Key Are Dropped</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>EXPDP导出全库报错ORA-01555</title>
		<link>https://www.dbant.com/2015/12/08/expdp_export_full_database_ora-01555/</link>
		
		<dc:creator><![CDATA[dbAnt]]></dc:creator>
		<pubDate>Tue, 08 Dec 2015 15:19:35 +0000</pubDate>
				<category><![CDATA[EXPDP/IMPDP]]></category>
		<category><![CDATA[TroubleShooting]]></category>
		<guid isPermaLink="false">http://www.dbant.com/?p=35</guid>

					<description><![CDATA[<p>[box style=&#8221;blue&#8221;]APPLIES TO:[/box] OS：Wind [&#8230;]</p>
<p><a href="https://www.dbant.com/2015/12/08/expdp_export_full_database_ora-01555/">EXPDP导出全库报错ORA-01555</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></description>
										<content:encoded><![CDATA[[box style=&#8221;blue&#8221;]<strong>APPLIES TO:</strong>[/box]
OS：Windows 2008 64bit</p>
<p>DB：ORACLE 11.2.0.3</p>
<p>&nbsp;</p>
[box style=&#8221;blue&#8221;]<b>SYMPTOMS</b>[/box]
<p>通过EXPDP导出全库，查看log发现如下报错：</p>
<blockquote><p>ORA-31693: 表数据对象 &#8220;AUDIT_GD&#8221;.&#8221;PUB_LOBFILE&#8221; 无法加载/卸载并且被跳过, 错误如下:<br />
ORA-02354: 导出/导入数据时出错<br />
ORA-01555: 快照过旧: 回退段号 7 (名称为 &#8220;_SYSSMU7_93985497$&#8221;) 过小<br />
已成功加载/卸载了主表 &#8220;EXP_DBA&#8221;.&#8221;JOB_EXP_FULL_2&#8243;</p></blockquote>
<p>&nbsp;</p>
[box style=&#8221;blue&#8221;]<b>CAUSE &amp; SOLUTION</b>[/box]
<p>从报错信息ORA-31693，我们可以看到由于&#8221;AUDIT_GD&#8221;.&#8221;PUB_LOBFILE&#8221;对象的UNDO段过期导致。我们知道LOB对象的UNDO段保留时间通过<strong>PCTVERSION</strong>和<strong>RETENTION</strong>参数控制。</p>
<p><strong><span style="color: #ff0000;">注意：</span></strong></p>
<p><span style="color: #ff0000;">1、SecureFiles类型的LOB，只能通过RETENTION参数控制。</span></p>
<p><span style="color: #ff0000;">2、BasicFiles类型的LOB，可以通过PCTVERSION <strong>或 </strong>RETENTION中的其中一个进行控制。</span></p>
<p><strong>PCTVERSION</strong>：表示整个BasicFiles LOB对象的空间允许被该LOB对象的UNDO段占用的最大百分比。</p>
<p><strong>RETENTION</strong>：表示保留的时间，单位秒。当数据库为自动UNDO段管理是，该参数为默认值，并参考undo_retention的参数值。</p>
<p>查看该LOB对象的UNDO段保留情况：</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select COLUMN_NAME,SECUREFILE,PCTVERSION,RETENTION from dba_lobs where OWNER=upper('AUDIT_GD') and TABLE_NAME=upper('PUB_LOBFILE') ;

COLUMN_NAME                    SEC PCTVERSION  RETENTION
------------------------------ --- ---------- ----------
LOB                            NO          10
TEXTLOB                        NO                    900
</pre>
<p>&nbsp;</p>
<p>查看数据库中使用UNDO段的最大保留时间：</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select max(maxquerylen) from v$undostat;

MAX(MAXQUERYLEN)
----------------
1839
</pre>
<p>&nbsp;</p>
<p>为了防止数据导出过程中UNDO段过期，增加undo_retention参数值：(<span style="color: #ff0000;"><strong>设置该参数之前，必须保证UNDO表空间有足够的空间</strong></span>)</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; alter system set undo_retention=2000 scope=both sid='*';
</pre>
<p>&nbsp;</p>
<p>设置LOB对象的UNDO段保留时间：</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; alter table AUDIT_GD.PUB_LOBFILE modify lob(LOB) (retention);
Table altered.

SQL&gt; alter table AUDIT_GD.PUB_LOBFILE modify lob(TEXTLOB) (retention);
Table altered.

SQL&gt; select COLUMN_NAME,SECUREFILE,PCTVERSION,RETENTION from dba_lobs where OWNER=upper('AUDIT_GD') and TABLE_NAME=upper('PUB_LOBFILE') ;

COLUMN_NAME                    SEC PCTVERSION  RETENTION
------------------------------ --- ---------- ----------
LOB                            NO                   2000
TEXTLOB                        NO                   2000
</pre>
<p>&nbsp;</p>
<p>修改完参数之后，再进行EXPDP导出。</p>
<p>&nbsp;</p>
<p>参考：ORA-31693, ORA-02354 and ORA-01555 with Export Datapump (文档 ID 1580798.1)</p>
<p>&nbsp;</p>
<p>版权所有，转载请注明出处：</p>
<blockquote class="wp-embedded-content" data-secret="VuHfZZdh4Z"><p><a href="https://www.dbant.com/2015/12/08/expdp_export_full_database_ora-01555/">EXPDP导出全库报错ORA-01555</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="《 EXPDP导出全库报错ORA-01555 》—dbAnt" src="https://www.dbant.com/2015/12/08/expdp_export_full_database_ora-01555/embed/#?secret=jJMD2dryuX#?secret=VuHfZZdh4Z" data-secret="VuHfZZdh4Z" width="500" height="282" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><a href="https://www.dbant.com/2015/12/08/expdp_export_full_database_ora-01555/">EXPDP导出全库报错ORA-01555</a>最先出现在<a href="https://www.dbant.com">dbAnt</a>。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
