<?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>IT WorldIT World</title>
	<atom:link href="http://blog.yannickjaquier.com/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.yannickjaquier.com</link>
	<description>RDBMS, Unix and many more...</description>
	<lastBuildDate>Wed, 15 May 2013 08:11:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>AWR baselines and performance comparison</title>
		<link>http://blog.yannickjaquier.com/oracle/awr-baselines-and-performance-comparison.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=awr-baselines-and-performance-comparison</link>
		<comments>http://blog.yannickjaquier.com/oracle/awr-baselines-and-performance-comparison.html#comments</comments>
		<pubDate>Wed, 08 May 2013 09:13:06 +0000</pubDate>
		<dc:creator>Yannick</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Automatic Workload Repository (AWR)]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://blog.yannickjaquier.com/?p=2084</guid>
		<description><![CDATA[Preamble While reviewing OCM exam objectives I saw that AWR baselines are in to-be-known list&#8230;. So decided to have a quick look and at same time understand this SYSTEM_MOVING_WINDOW default baseline that appears in Grid/Cloud Control. As you can read in blogs of well known Oracle worldwide experts (few references below), increasing performance of an [...]]]></description>
				<content:encoded><![CDATA[<div class='toc wptoc'>
<h2>Table Of Contents</h2>
<ol class='toc-odd level-1'>
	<li>
		<a href="#Preamble">Preamble</a>
	</li>
	<li>
		<a href="#Good_performance">Good performance</a>
	</li>
	<li>
		<a href="#Bad_performance">Bad performance</a>
	</li>
	<li>
		<a href="#Performance_improved">Performance improved</a>
	</li>
	<li>
		<a href="#Conclusion">Conclusion</a>
	</li>
	<li>
		<a href="#References">References</a>
	</li>
</ol>
</div>
<div class='wptoc-end'>&nbsp;</div>
<p><span id="more-2084"></span></p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Preamble"><h1>Preamble</h1></span>
<p>While reviewing OCM exam objectives I saw that AWR baselines are in to-be-known list&#8230;. So decided to have a quick look and at same time understand this SYSTEM_MOVING_WINDOW default baseline that appears in Grid/Cloud Control.</p>
<p>As you can read in blogs of well known Oracle worldwide experts (few references below), increasing performance of an Oracle database is all about reducing DB time metric (that you can find in AWR reports). As a DBA I have quite often been in front of internal customers stating: performance of database were good, we did not change anything and now performance are awful, please correct problem as soon as possible&#8230;. I&#8217;m sure most of you have faced this in their DBA life&#8230;</p>
<p>So come in loop AWR baselines that are really great and can save your day !</p>
<p>For the test case I create the below table and fill it with 10,000 rows:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">DROP</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> test1;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">CREATE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> test1<span style="color: #66cc66;">&#40;</span>id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span><span style="color: #66cc66;">,</span> descr <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLESPACE</span> users;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">DECLARE</span>
i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
nbrows <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">BEGIN</span>
  i:<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;
  nbrows:<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">10000</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXIT</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHEN</span> i<span style="color: #66cc66;">&gt;</span>nbrows;
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INSERT</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUES</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">TO_CHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">TO_DATE</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'j'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'jsp'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    i:<span style="color: #66cc66;">=</span>i<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">COMMIT</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span>;
<span style="color: #66cc66;">/</span>
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXEC</span> DBMS_STATS.GATHER_TABLE_STATS<span style="color: #66cc66;">&#40;</span>ownname<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'yjaquier'</span><span style="color: #66cc66;">,</span> tabname<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'test1'</span><span style="color: #66cc66;">,</span> estimate_percent<span style="color: #66cc66;">=&gt;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">NULL</span><span style="color: #66cc66;">,</span> method_opt<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'FOR ALL INDEXED COLUMNS SIZE AUTO'</span><span style="color: #66cc66;">,</span> degree<span style="color: #66cc66;">=&gt;</span>DBMS_STATS.DEFAULT_DEGREE<span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">CASCADE</span><span style="color: #66cc66;">=&gt;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">TRUE</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Modus operandi will be multiple select on this TEST1 table using a PL/SQL block, then I will multiply by 10 number of rows in this table and run same PL/SQL block and finally run an optimized (to be proven) PL/SQL block. This is symptomatic of a newly created application that starts with very few rows and get bigger when users fill-in information&#8230;</p>
<p>Testing has been done using Oracle Enterprise 11.2.0.3 running on a 16 cores box (not dedicated) with Red Hat Enterprise Linux Server release 5.5 (Tikanga). For testing purpose I have reduced AWR frequency to its minimum i.e. 10 minutes.</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Good_performance"><h1>Good performance</h1></span>
<p>The PL/SQL block I aim to use is the following. You will notice the hard parsing as no bind variable and as many select as number of rows in TEST1 table that has no indexes:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">DECLARE</span> <span style="">/* Yannick */</span>
  i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
  sql_stmt <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VARCHAR2</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span>;
	max_id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">BEGIN</span>
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">MAX</span><span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> max_id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> yjaquier.test1;
  DBMS_RANDOM.SEED<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SYSDATE</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FOR</span> i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IN</span> <span style="color: #cc66cc;">1</span>..max_id
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>
    sql_stmt:<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'SELECT /* Yannick */ descr FROM yjaquier.test1 WHERE id='</span> <span style="color: #66cc66;">||</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ROUND</span><span style="color: #66cc66;">&#40;</span>DBMS_RANDOM.<span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span>max_id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXECUTE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IMMEDIATE</span> sql_stmt;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span>;
<span style="color: #66cc66;">/</span></pre></td></tr></table></div>

<p>With 10,000 rows in the table the PL/SQL block is executed in 39.83 seconds, I take a baseline using below command:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXEC</span> DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">13264</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">13265</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'Good performance'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
PL<span style="color: #66cc66;">/</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SQL</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">PROCEDURE</span> successfully completed.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> baseline_id<span style="color: #66cc66;">,</span>baseline_name<span style="color: #66cc66;">,</span>baseline_type<span style="color: #66cc66;">,</span>start_snap_id<span style="color: #66cc66;">,</span>end_snap_id
     <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_hist_baseline;
&nbsp;
BASELINE_ID BASELINE_NAME                                                    BASELINE_TYPE START_SNAP_ID END_SNAP_ID
<span style="color: #808080; font-style: italic;">----------- ---------------------------------------------------------------- ------------- ------------- -----------</span>
          <span style="color: #cc66cc;">2</span> Good performance                                                 STATIC                <span style="color: #cc66cc;">13264</span>       <span style="color: #cc66cc;">13265</span>
          <span style="color: #cc66cc;">0</span> SYSTEM_MOVING_WINDOW                                             MOVING_WINDOW         <span style="color: #cc66cc;">13237</span>       <span style="color: #cc66cc;">13265</span></pre></td></tr></table></div>

<p>The user created baselines are of type STATIC, versus the default SYSTEM_MOVING_WINDOW baselines that is of type MOVING. Windows moving size is in DBA_HIST_BASELINE.MOVING_WINDOW_SIZE column and alterable with DBMS_WORKLOAD_REPOSITORY.MODIFY_BASELINE_WINDOW_SIZE procedure. Even using baseline templates it is not possible to create a new moving window baseline.</p>
<p>The baseline template helps you, for example, to create a repeating baselines (every Monday between 8 AM and 8 PM for example), their type will be GENERATED. DBA_HIST_BASELINE_DETAILS, DBA_HIST_BASELINE_METADATA and DBA_HIST_BASELINE_TEMPLATE view display all details of baselines and templates.</p>
<p>The moving baseline aim is to compare how performance of your database evolve over time, in other words is your performance going in right or wrong direction ?</p>
<p>You can display baselines statistics and metric using the two below procedures of DBMS_WORKLOAD_REPOSITORY package:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SET</span> lines <span style="color: #cc66cc;">200</span> pages <span style="color: #cc66cc;">1000</span>
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> metric_name<span style="color: #66cc66;">,</span> metric_unit<span style="color: #66cc66;">,</span> average<span style="color: #66cc66;">,</span> minimum<span style="color: #66cc66;">,</span> maximum
     <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span><span style="color: #66cc66;">&#40;</span>DBMS_WORKLOAD_REPOSITORY.SELECT_BASELINE_METRIC<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Good performance'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
     <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ORDER</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">BY</span> metric_name;
&nbsp;
METRIC_NAME                                                      METRIC_UNIT                                                         AVERAGE    MINIMUM    MAXIMUM
<span style="color: #808080; font-style: italic;">---------------------------------------------------------------- ---------------------------------------------------------------- ---------- ---------- ----------</span>
Active Parallel Sessions                                         Sessions                                                                  <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">0</span>
Active Serial Sessions                                           Sessions                                                               <span style="color: #cc66cc;">1.35</span>          <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">3</span>
Average Active Sessions                                          Active Sessions                                                  .185770022          <span style="color: #cc66cc;">0</span> .903106368
Average Synchronous Single<span style="color: #66cc66;">-</span>Block Read Latency                    Milliseconds                                                     <span style="color: #cc66cc;">2.65291323</span>          <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">8.22211738</span>
Background CPU Usage Per Sec                                     CentiSeconds Per <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SECOND</span>                                          .914520922          <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">6.01504323</span>
Background Checkpoints Per Sec                                   <span style="color: #993333; font-weight: bold; text-transform: uppercase;">CHECK</span> Points Per <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SECOND</span>                                                   <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">0</span>
Background <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TIME</span> Per Sec                                          Active Sessions                                                  .029696648          <span style="color: #cc66cc;">0</span> .217157599
Branch Node Splits Per Sec                                       Splits Per <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SECOND</span>                                                         <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">0</span>
Branch Node Splits Per Txn                                       Splits Per Txn                                                            <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">0</span>
Buffer Cache Hit Ratio                                           % <span style="color: #66cc66;">&#40;</span>LogRead <span style="color: #66cc66;">-</span> PhyRead<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span>LogRead                                    <span style="color: #cc66cc;">98.6432958</span>          <span style="color: #cc66cc;">0</span>        <span style="color: #cc66cc;">100</span>
CPU Usage Per Sec                                                CentiSeconds Per <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SECOND</span>                                          <span style="color: #cc66cc;">3.39302187</span>          <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">9.67427669</span>
.
.
.
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span><span style="color: #66cc66;">&#40;</span>DBMS_WORKLOAD_REPOSITORY.SELECT_BASELINE_DETAILS<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
      DBID BASELINE_ID INSTANCE_NUMBER START_SNAP_ID START_SNAP_TIME                                                             END_SNAP_ID
<span style="color: #808080; font-style: italic;">---------- ----------- --------------- ------------- --------------------------------------------------------------------------- -----------</span>
END_SNAP_TIME                                                               SHU ERROR_COUNT PCT_TOTAL_TIME
<span style="color: #808080; font-style: italic;">--------------------------------------------------------------------------- --- ----------- --------------</span>
<span style="color: #cc66cc;">3673847771</span>           <span style="color: #cc66cc;">2</span>               <span style="color: #cc66cc;">1</span>         <span style="color: #cc66cc;">13264</span> 07<span style="color: #66cc66;">-</span>MAY<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">13</span> 10.10.37.940 AM                                                         <span style="color: #cc66cc;">13265</span>
07<span style="color: #66cc66;">-</span>MAY<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">13</span> 10.20.38.541 AM                                                   NO            <span style="color: #cc66cc;">0</span>            <span style="color: #cc66cc;">100</span></pre></td></tr></table></div>

<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Bad_performance"><h1>Bad performance</h1></span>
<p>Then I now fill (using same method) the TEST1 table with 1,000,000 rows and I execute the exact same PL/SQL block that now elapses in 8 minutes and 40.70 seconds. I create a new baseline that I call &#8216;Bad performance&#8217;:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXEC</span> DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">13266</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">13267</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'Bad performance'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
PL<span style="color: #66cc66;">/</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SQL</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">PROCEDURE</span> successfully completed.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> baseline_id<span style="color: #66cc66;">,</span>baseline_name<span style="color: #66cc66;">,</span>baseline_type<span style="color: #66cc66;">,</span>start_snap_id<span style="color: #66cc66;">,</span>end_snap_id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_hist_baseline;
&nbsp;
BASELINE_ID BASELINE_NAME                                                    BASELINE_TYPE START_SNAP_ID END_SNAP_ID
<span style="color: #808080; font-style: italic;">----------- ---------------------------------------------------------------- ------------- ------------- -----------</span>
          <span style="color: #cc66cc;">2</span> Good performance                                                 STATIC                <span style="color: #cc66cc;">13264</span>       <span style="color: #cc66cc;">13265</span>
          <span style="color: #cc66cc;">3</span> Bad performance                                                  STATIC                <span style="color: #cc66cc;">13266</span>       <span style="color: #cc66cc;">13267</span>
          <span style="color: #cc66cc;">0</span> SYSTEM_MOVING_WINDOW                                             MOVING_WINDOW         <span style="color: #cc66cc;">13237</span>       <span style="color: #cc66cc;">13267</span></pre></td></tr></table></div>

<p>To compare the two baselines you have multiple option DBMS_WORKLOAD_REPOSITORY.AWR_DIFF_REPORT_HTML, DBMS_WORKLOAD_REPOSITORY.AWR_DIFF_REPORT_TEXT or awrddrpt.sql script located in $ORACLE_HOME/rdbms/admin directory. I prefer to use awrddrpt.sql script and display result in my web browser:</p>
<p><a href="http://blog.yannickjaquier.com/wp-content/uploads/2013/05/Good-versus-bad.html">Good versus bad</a></p>
<p>So what do we see (non exhaustively) ?:</p>
<ul>
<li>DB time moved from 2.2 (min) to 9.7 (min) over a 10 minutes period.</li>
<li>Top 5 wait events move from I/O waits (db file sequential read &#038; direct path read) to CPU at more than 91%.</li>
<li>parse time elapsed, DB CPU and hard parse elapsed time have increased a lot.</li>
<li>sql_id 81uvdbt46vt5p (my PL/SQL block, thanks to /* Yannick */ comment to retrieve it) is the one that has most been impacted between the two periods (% of DB time, elapsed time, CPU time, &#8230;).</li>
</ul>
<p>So clearly something has changed and you can peacefully forward to applicative team and move to something else&#8230; But as a good DBA you may, as well, have a look&#8230;</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Performance_improved"><h1>Performance improved</h1></span>
<p>To try to optimize the PL/SQL code I create an index on id column:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">CREATE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span> test1_idx_id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ON</span> test1<span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLESPACE</span> users;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXEC</span> DBMS_STATS.GATHER_TABLE_STATS<span style="color: #66cc66;">&#40;</span>ownname<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'yjaquier'</span><span style="color: #66cc66;">,</span> tabname<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'test1'</span><span style="color: #66cc66;">,</span> estimate_percent<span style="color: #66cc66;">=&gt;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">NULL</span><span style="color: #66cc66;">,</span> method_opt<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'FOR ALL INDEXED COLUMNS SIZE AUTO'</span><span style="color: #66cc66;">,</span> degree<span style="color: #66cc66;">=&gt;</span>DBMS_STATS.DEFAULT_DEGREE<span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">CASCADE</span><span style="color: #66cc66;">=&gt;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">TRUE</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>And remove the hard coded value by using a bind variable:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">DECLARE</span> <span style="">/* Yannick */</span>
  i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
  sql_stmt <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VARCHAR2</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span>;
	max_id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">BEGIN</span>
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">MAX</span><span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> max_id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> yjaquier.test1;
  DBMS_RANDOM.SEED<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SYSDATE</span><span style="color: #66cc66;">&#41;</span>;
  sql_stmt:<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'SELECT /* Yannick */ descr FROM yjaquier.test1 WHERE id=:id'</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FOR</span> i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IN</span> <span style="color: #cc66cc;">1</span>..max_id
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXECUTE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IMMEDIATE</span> sql_stmt <span style="color: #993333; font-weight: bold; text-transform: uppercase;">USING</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ROUND</span><span style="color: #66cc66;">&#40;</span>DBMS_RANDOM.<span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span>max_id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span>;
<span style="color: #66cc66;">/</span></pre></td></tr></table></div>

<p>The PL/SQL block is now executed in 24.50 seconds. I create a new baseline called &#8216;Performance improved&#8217;:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXEC</span> DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">13268</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">13269</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'Performance improved'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
PL<span style="color: #66cc66;">/</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SQL</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">PROCEDURE</span> successfully completed.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> baseline_id<span style="color: #66cc66;">,</span>baseline_name<span style="color: #66cc66;">,</span>baseline_type<span style="color: #66cc66;">,</span>start_snap_id<span style="color: #66cc66;">,</span>end_snap_id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_hist_baseline;
&nbsp;
BASELINE_ID BASELINE_NAME                                                    BASELINE_TYPE START_SNAP_ID END_SNAP_ID
<span style="color: #808080; font-style: italic;">----------- ---------------------------------------------------------------- ------------- ------------- -----------</span>
          <span style="color: #cc66cc;">2</span> Good performance                                                 STATIC                <span style="color: #cc66cc;">13264</span>       <span style="color: #cc66cc;">13265</span>
          <span style="color: #cc66cc;">3</span> Bad performance                                                  STATIC                <span style="color: #cc66cc;">13266</span>       <span style="color: #cc66cc;">13267</span>
          <span style="color: #cc66cc;">4</span> Performance improved                                             STATIC                <span style="color: #cc66cc;">13268</span>       <span style="color: #cc66cc;">13269</span>
          <span style="color: #cc66cc;">0</span> SYSTEM_MOVING_WINDOW                                             MOVING_WINDOW         <span style="color: #cc66cc;">13238</span>       <span style="color: #cc66cc;">13269</span></pre></td></tr></table></div>

<p>The comparison report is the following:</p>
<p><a href="http://blog.yannickjaquier.com/wp-content/uploads/2013/05/Bad-versus-improved.html">Bad versus improved</a></p>
<p>So what do we see (non exhaustively) ?:</p>
<ul>
<li>DB time moved from 9.7 (min) to 2.9 (min) over a 10 minutes period.</li>
<li>Top 5 wait events move from CPU at more than 91% to I/O waits (db file sequential read &#038; direct path read).</li>
<li>parse time elapsed, DB CPU and hard parse elapsed time have decreased a lot.</li>
<li>sql_id 81uvdbt46vt5p load (% of DB time, elapsed time, CPU time, &#8230;) has decreased because not present in third run (performance improved) you would say&#8230; But we can retrieve improved PL/SQL sql_id, again, using /* Yannick */ comment and now see it is 28ja91pnth38j. By comparing we can see that main performance indicator (% of DB time, elapsed time, CPU time, &#8230;) have decreased.</li>
</ul>
<p>This sql_id change also demonstrate, was it needed to re-demonstrate it ?, that checking performance improvement, or not, is not always a piece of cake&#8230;</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Conclusion"><h1>Conclusion</h1></span>
<p>All can also be seen graphically in Cloud Control at a very high level but comparing period and keeping baselines is best way to be able to go in details:</p>
<div id="attachment_2083" class="wp-caption aligncenter" style="width: 1690px"><a href="http://blog.yannickjaquier.com/wp-content/uploads/2013/05/awr-baselines-1.png" rel="lightbox[2084]" title="AWR baselines and performance comparison"><img src="http://blog.yannickjaquier.com/wp-content/uploads/2013/05/awr-baselines-1.png" alt="AWR baseline 1" width="1680" height="1010" class="size-full wp-image-2083" /></a><p class="wp-caption-text">AWR baseline 1</p></div>
<p>As a DBA I would always keep a baseline when users are happy with performance. This would provide invaluable piece of information when things start to go wrong and that you need to prove from where are coming problems&#8230;</p>
<p>For the fun I have generated the comparison report between good performance and performance improved baselines:</p>
<p><a href="http://blog.yannickjaquier.com/wp-content/uploads/2013/05/Good-versus-improved.html">Good versus improved</a></p>
<p>Without entering too much in details we can see that even with a 10 times more figures the performance globally is almost flat, I would love achieve it for all our environments&#8230;</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="References"><h1>References</h1></span>
<ul>
<li><a href="http://www.oracle-base.com/articles/11g/awr-baseline-enhancements-11gr1.php">AWR Baseline Enhancements in Oracle Database 11g Release 1</a></li>
<li><a href="http://oracledoug.com/serendipity/index.php?/archives/1429-Time-Matters-DB-Time.html">Time Matters &#8211; DB Time</a></li>
<li><a href="http://www.peoug.org/icontact/presentations/GrahamWood_DBTimeTuningTheoryandPractice.pdf">Back to Basics: DB Time Performance Tuning: Theory and Practice</a></li>
<li><a href="http://uhesse.com/2013/04/16/evidence-for-successful-oracle-performance-tuning/">Evidence for successful #Oracle Performance Tuning</a></li>
</ul>
<!-- Start Shareaholic Recommendations Automatic --><!-- End Shareaholic Recommendations Automatic -->]]></content:encoded>
			<wfw:commentRss>http://blog.yannickjaquier.com/oracle/awr-baselines-and-performance-comparison.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL 5.6 and MySQL 5.5 performance comparison</title>
		<link>http://blog.yannickjaquier.com/mysql/mysql-5-6-and-mysql-5-5-performance-comparison.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mysql-5-6-and-mysql-5-5-performance-comparison</link>
		<comments>http://blog.yannickjaquier.com/mysql/mysql-5-6-and-mysql-5-5-performance-comparison.html#comments</comments>
		<pubDate>Fri, 12 Apr 2013 14:34:46 +0000</pubDate>
		<dc:creator>Yannick</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Benchmark]]></category>

		<guid isPermaLink="false">http://blog.yannickjaquier.com/?p=2047</guid>
		<description><![CDATA[Preamble I have seen many blog post over Internet questioning the performances of MySQL 5.6. There is even one on world know mysqlperformance blog from Peter Zaitsev called Is MySQL 5.6 slower than MySQL 5.5?. I had caution look to all comments and I have to say that results from various person that replied were [...]]]></description>
				<content:encoded><![CDATA[<div class='toc wptoc'>
<h2>Table Of Contents</h2>
<ol class='toc-odd level-1'>
	<li>
		<a href="#Preamble">Preamble</a>
	</li>
	<li>
		<a href="#Configuration">Configuration</a>
	</li>
	<li>
		<a href="#Results_and_conclusion">Results and conclusion</a>
	</li>
	<li>
		<a href="#References">References</a>
	</li>
</ol>
</div>
<div class='wptoc-end'>&nbsp;</div>
<p><span id="more-2047"></span></p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Preamble"><h1>Preamble</h1></span>
<p>I have seen many blog post over Internet questioning the performances of MySQL 5.6. There is even one on world know mysqlperformance blog from Peter Zaitsev called <a href="http://www.mysqlperformanceblog.com/2013/02/18/is-mysql-5-6-slower-than-mysql-5-5/">Is MySQL 5.6 slower than MySQL 5.5?</a>. I had caution look to all comments and I have to say that results from various person that replied were diverging a lot&#8230;</p>
<p>On top of this, internally I have more and more pressure to make MySQL 5.6 standard release for MySQL. So I have finally decided to conduct very basic test using a tool I have already work on called <a href="http://blog.yannickjaquier.com/linux/sysbench.html">Sysbench</a> (0.4.12).</p>
<p>For this testing I have used Oracle Linux Server release 6.4 64 bits (updated from Oracle public yum at the time of writing of this post) under VirtualBox 4.2.10 r84104. I have allocated 2 cores of my physical processor (Intel Xeon E5507 at 2.27 GHz) and 4GB of RAM (I have 8 GB physical RAM). I downloaded MySQL Community Server generic Linux 64 bits edition (tar files) for MySQL 5.5.30 and MySQL 5.6.10 (latest releases available at the time of writing of this post).</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Configuration"><h1>Configuration</h1></span>
<p>To have two MySQL installations on same server I had to refine a bit my way of installing MySQL, so chosen the below naming convention:</p>
<pre>
/mysql/backup/x.y.z for backup files if any
/mysql/data01/x.y.z for database files (letting capability to create data02 to spread the I/Os)
/mysql/dump/x.y.z for log files
/mysql/logs/x.y.z for mysql binary logs
/mysql/software/x.y.z for binaries
</pre>
<p>Where x.y.z if MySQL exact release, under /mysql/software/x.y.z I create a conf directory to store my.cnf, pid and lock files.</p>
<p>I add below aliases and PATH to mysql OS account:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>sysbench<span style="color: #000000; font-weight: bold;">/</span>sysbench-0.4.12<span style="color: #000000; font-weight: bold;">/</span>sysbench
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> PATH
&nbsp;
<span style="color: #666666; font-style: italic;"># MySQL</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">start_mysql55</span>=<span style="color: #ff0000;">'cd /mysql/software/5.5.30/; ./bin/mysqld_safe --defaults-file=/mysql/software/5.5.30/conf/my.cnf &amp;'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">stop_mysql55</span>=<span style="color: #ff0000;">&quot;kill \<span style="color: #780078;">`ps -ef | grep /mysql/software/5.5.30/bin/mysqld | grep -v grep | awk '{print \$2}'\`</span>&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">start_mysql56</span>=<span style="color: #ff0000;">'cd /mysql/software/5.6.10/; ./bin/mysqld_safe --defaults-file=/mysql/software/5.6.10/conf/my.cnf &amp;'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">stop_mysql56</span>=<span style="color: #ff0000;">&quot;kill \<span style="color: #780078;">`ps -ef | grep /mysql/software/5.6.10/bin/mysqld | grep -v grep | awk '{print \$2}'\`</span>&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">mysql55</span>=<span style="color: #ff0000;">'/mysql/software/5.5.30/bin/mysql --defaults-file=/mysql/software/5.5.30/conf/my.cnf --user=root'</span>
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">mysql56</span>=<span style="color: #ff0000;">'/mysql/software/5.6.10/bin/mysql --defaults-file=/mysql/software/5.6.10/conf/my.cnf --user=root'</span></pre></td></tr></table></div>

<p>Then configuring Sysbench for MySQL 5.5 or 5.6 is as simple as (please refer to my other post for issues). I have chosen to recompile it using libraries of exact release I&#8217;m currently testing:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-mysql-includes</span>=<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>include <span style="color: #660033;">--with-mysql-libs</span>=<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LD_LIBRARY_PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>lib</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-mysql-includes</span>=<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>include <span style="color: #660033;">--with-mysql-libs</span>=<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LD_LIBRARY_PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>lib</pre></td></tr></table></div>

<p>On both MySQL instances I created a sysbench account (test default database will be reused):</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">GRANT</span> <span style="color: #990099; font-weight: bold;">ALL</span> <span style="color: #990099; font-weight: bold;">PRIVILEGES</span> <span style="color: #990099; font-weight: bold;">ON</span> <span style="color: #CC0099;">*</span>.<span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">TO</span> <span style="color: #008000;">'sysbench'</span>@<span style="color: #008000;">'localhost'</span> IDENTIFIED BY <span style="color: #008000;">'sysbench'</span> <span style="color: #990099; font-weight: bold;">WITH</span> <span style="color: #990099; font-weight: bold;">GRANT</span> <span style="color: #990099; font-weight: bold;">OPTION</span><span style="color: #000033;">;</span>
FLUSH <span style="color: #990099; font-weight: bold;">PRIVILEGES</span><span style="color: #000033;">;</span></pre></td></tr></table></div>

<p>To create my my.cnf file I started from <strong>./support-files/my-small.cnf</strong> file adding few specific parameters, no memory tuning, just straightforward. The one for MySQL 5.5.30:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>client<span style="color: #7a0874; font-weight: bold;">&#93;</span>
port = <span style="color: #000000;">3316</span>
socket = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>mysql.sock
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mysqld<span style="color: #7a0874; font-weight: bold;">&#93;</span>
port = <span style="color: #000000;">3316</span>
socket = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>mysql.sock
basedir = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.5.30
datadir = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>data01<span style="color: #000000; font-weight: bold;">/</span>5.5.30
pid-file = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>5.5.30.pid
log-bin = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>mysql-bin.log
log_error = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>dump<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>server1.err
slow_query_log_file = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>dump<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>slow.log
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = <span style="color: #000000;">4</span>
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
server-id	= <span style="color: #000000;">1</span>
performance_schema = off
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mysqldump<span style="color: #7a0874; font-weight: bold;">&#93;</span>
quick
max_allowed_packet = 16M
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mysql<span style="color: #7a0874; font-weight: bold;">&#93;</span>
no-auto-rehash
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>myisamchk<span style="color: #7a0874; font-weight: bold;">&#93;</span>
key_buffer_size = 8M
sort_buffer_size = 8M
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mysqlhotcopy<span style="color: #7a0874; font-weight: bold;">&#93;</span>
interactive-timeout</pre></td></tr></table></div>

<p>And the one for MySQL 5.6.10:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>client<span style="color: #7a0874; font-weight: bold;">&#93;</span>
port = <span style="color: #000000;">3326</span>
socket = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>mysql.sock
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mysqld<span style="color: #7a0874; font-weight: bold;">&#93;</span>
port = <span style="color: #000000;">3326</span>
socket = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>mysql.sock
basedir = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.6.10
datadir = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>data01<span style="color: #000000; font-weight: bold;">/</span>5.6.10
pid-file = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>5.6.10.pid
log-bin = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>mysql-bin.log
log_error = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>dump<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>server1.err
slow_query_log_file = <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>dump<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>slow.log
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = <span style="color: #000000;">4</span>
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
server-id = <span style="color: #000000;">1</span>
innodb_file_per_table = off
performance_schema = off
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mysqldump<span style="color: #7a0874; font-weight: bold;">&#93;</span>
quick
max_allowed_packet = 16M
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mysql<span style="color: #7a0874; font-weight: bold;">&#93;</span>
no-auto-rehash
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>myisamchk<span style="color: #7a0874; font-weight: bold;">&#93;</span>
key_buffer_size = 8M
sort_buffer_size = 8M
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>mysqlhotcopy<span style="color: #7a0874; font-weight: bold;">&#93;</span>
interactive-timeout</pre></td></tr></table></div>

<p>Finally sysbench commands are:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">sysbench <span style="color: #660033;">--test</span>=oltp <span style="color: #660033;">--mysql-socket</span>=<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.5.30<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>mysql.sock <span style="color: #660033;">--mysql-port</span>=<span style="color: #000000;">3316</span> <span style="color: #660033;">--mysql-user</span>=sysbench <span style="color: #660033;">--mysql-password</span>=sysbench
<span style="color: #660033;">--mysql-db</span>=<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">--oltp-table-size</span>=<span style="color: #000000;">10000000</span> <span style="color: #660033;">--num-threads</span>=<span style="color: #000000;">1</span> <span style="color: #660033;">--oltp-read-only</span>=on <span style="color: #660033;">--init-rng</span>=on <span style="color: #660033;">--max-requests</span>=<span style="color: #000000;">0</span> <span style="color: #660033;">--max-time</span>=<span style="color: #000000;">300</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>prepare <span style="color: #000000; font-weight: bold;">|</span> run<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
sysbench <span style="color: #660033;">--test</span>=oltp <span style="color: #660033;">--mysql-socket</span>=<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>software<span style="color: #000000; font-weight: bold;">/</span>5.6.10<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>mysql.sock <span style="color: #660033;">--mysql-port</span>=<span style="color: #000000;">3326</span> <span style="color: #660033;">--mysql-user</span>=sysbench <span style="color: #660033;">--mysql-password</span>=sysbench
<span style="color: #660033;">--mysql-db</span>=<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">--oltp-table-size</span>=<span style="color: #000000;">10000000</span> <span style="color: #660033;">--num-threads</span>=<span style="color: #000000;">1</span> <span style="color: #660033;">--oltp-read-only</span>=on <span style="color: #660033;">--init-rng</span>=on <span style="color: #660033;">--max-requests</span>=<span style="color: #000000;">0</span> <span style="color: #660033;">--max-time</span>=<span style="color: #000000;">300</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>prepare <span style="color: #000000; font-weight: bold;">|</span> run<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></td></tr></table></div>

<p>Remark:<br />So creating a table with 10 million rows (2400 MB around), initializing random number before each test and running it for 5 minutes with different number of threads (from 1 to 64). Reading multiple posts around and having double checked in MySQL 5.6 official documentation it appears that performance schema is activated by default starting with MySQL 5.6.6 (off by default for previous releases and in all 5.5.x releases) so the performance_schema = off in my.cnf. I finally tested performance activating it as I personally flag this feature with high interest&#8230;<br />Even if it does not change too much as sysbench benchmark is made of one table I also set innodb_file_per_table to off to avoid having one InnoDB file per table and club all of them in big ibdata1 datafile.</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Results_and_conclusion"><h1>Results and conclusion</h1></span>
<table>
<tr>
<th>Number of threads</th>
<th>MySQL 5.5.30<br />Number of TPS</th>
<th>MySQL 5.6.10<br />Performance Schema=off, number of TPS</th>
<th>MySQL 5.6.10<br />Performance Schema=on, number of TPS</th>
</tr>
<tr>
<td>1</td>
<td>143</td>
<td>132</td>
<td>124</td>
</tr>
<tr>
<td>8</td>
<td>459</td>
<td>463</td>
<td>388</td>
</tr>
<tr>
<td>16</td>
<td>463</td>
<td>463</td>
<td>388</td>
</tr>
<tr>
<td>32</td>
<td>432</td>
<td>453</td>
<td>383</td>
</tr>
<tr>
<td>64</td>
<td>417</td>
<td>441</td>
<td>370</td>
</tr>
</table>
<p>With an Excel chart:</p>
<div id="attachment_2067" class="wp-caption aligncenter" style="width: 842px"><a href="http://blog.yannickjaquier.com/wp-content/uploads/2013/04/mysql-5.6-performance.png" rel="lightbox[2047]" title="MySQL 5.6 and MySQL 5.5 performance comparison"><img src="http://blog.yannickjaquier.com/wp-content/uploads/2013/04/mysql-5.6-performance.png" alt="MySQL 5.6 vs MySQL 5.5 performance" width="832" height="492" class="size-full wp-image-2067" /></a><p class="wp-caption-text">MySQL 5.6 vs MySQL 5.5 performance</p></div>
<p>From my small test there is <strong>not much difference from performance point of view</strong> between MySQL 5.5 and MySQL 5.6&#8230; if you deactivate Performance Schema. Even if it adds lots of value it may impact your workload up to 20%&#8230; With pretty high number of threads (>16) I even see MySQL 5.6 in front of MySQL 5.5.</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="References"><h1>References</h1></span>
<ul>
<li><a href="http://www.mysqlperformanceblog.com/2013/02/18/is-mysql-5-6-slower-than-mysql-5-5/">Is MySQL 5.6 slower than MySQL 5.5?</a></li>
</ul>
<!-- Start Shareaholic Recommendations Automatic --><!-- End Shareaholic Recommendations Automatic -->]]></content:encoded>
			<wfw:commentRss>http://blog.yannickjaquier.com/mysql/mysql-5-6-and-mysql-5-5-performance-comparison.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Media recovery with NOLOGGING tables</title>
		<link>http://blog.yannickjaquier.com/oracle/media-recovery-with-nologging-tables.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=media-recovery-with-nologging-tables</link>
		<comments>http://blog.yannickjaquier.com/oracle/media-recovery-with-nologging-tables.html#comments</comments>
		<pubDate>Fri, 15 Mar 2013 09:00:02 +0000</pubDate>
		<dc:creator>Yannick</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Data Recovery Advisor]]></category>

		<guid isPermaLink="false">http://blog.yannickjaquier.com/?p=2015</guid>
		<description><![CDATA[Preamble There&#8217;s been a long debate with teammates about usage of NOLOGGING in our Oracle databases. Some application manager have discovered (and experienced) that some objects may be unrecoverable when using this clause on the opposite few DBAs wanted to audit all their databases to simply remove it. The performance gain using it well is [...]]]></description>
				<content:encoded><![CDATA[<div class='toc wptoc'>
<h2>Table Of Contents</h2>
<ol class='toc-odd level-1'>
	<li>
		<a href="#Preamble">Preamble</a>
	</li>
	<li>
		<a href="#Nologging_and_CTAS">Nologging and CTAS</a>
	</li>
	<li>
		<a href="#Nologging_and_insert_command">Nologging and insert command</a>
	</li>
	<li>
		<a href="#Tablespaces_logging_attributes">Tablespaces logging attributes</a>
	</li>
	<li>
		<a href="#RMAN_and_nologging_operations">RMAN and nologging operations</a>
	</li>
	<li>
		<a href="#References">References</a>
	</li>
</ol>
</div>
<div class='wptoc-end'>&nbsp;</div>
<p><span id="more-2015"></span></p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Preamble"><h1>Preamble</h1></span>
<p>There&#8217;s been a long debate with teammates about usage of NOLOGGING in our Oracle databases. Some application manager have discovered (and experienced) that some objects may be unrecoverable when using this clause on the opposite few DBAs wanted to audit all their databases to simply remove it. The performance gain using it well is obvious but to really understand what&#8217;s really doing this NOLOGGING option and the (bad) consequences of its usage I had to come back to <a href="http://docs.oracle.com/cd/E11882_01/server.112/e26088/clauses005.htm#CJAHABGF">official documentation</a>. The default logging mode is the one of the tablespace (and the one of the tablespace is LOGGING).</p>
<p>In this blog post I will focus on what I rate the standard DML/DDL commands we execute the most i.e. INSERT, Create Table As Select (CTAS) and CREATE INDEX.</p>
<p>Few <em>evidences</em>:</p>
<ul>
<li>Standard INSERT and UPDATE are always logged whatever LOGGING/NOLOGGING option chosen.</li>
<li>Direct-path INSERT (APPEND or APPEND_VALUES hints) supported by NOLOGGING option.</li>
<li>Direct Loader (SQL*Loader) supported by NOLOGGING option.</li>
</ul>
<p>Testing has been done on Oracle Linux Server release 6.3 using Oracle 11.2.0.3. My database is in archivelog mode as I&#8217;m doing datafile recovery&#8230;</p>
<p>As clearly written by <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5280714813869">Tom Kyte</a> don&#8217;t be shy when creating your test table. In clear if your NOLOGGING test table is too small then Oracle will generate redo for it and bypass the NOLOGGING option&#8230; The post also contains a very interesting table comparing when redo are generated with database in archivelog/noarchivelog mode and insert method used.</p>
<p>To perform this test I have created an USERS tablespace with one datafile:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> FILE_ID<span style="color: #66cc66;">,</span>FILE_NAME <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_data_files <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span>  TABLESPACE_NAME<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'USERS'</span>;
&nbsp;
   FILE_ID FILE_NAME
<span style="color: #808080; font-style: italic;">---------- --------------------------------------------------</span>
         <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">/</span>u01<span style="color: #66cc66;">/</span>app<span style="color: #66cc66;">/</span>oracle<span style="color: #66cc66;">/</span>oradata<span style="color: #66cc66;">/</span>orcl<span style="color: #66cc66;">/</span>users01.dbf</pre></td></tr></table></div>

<p>When the tablespace is still empty I have taken a backup using RMAN and:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">RMAN<span style="color: #000000; font-weight: bold;">&gt;</span> backup datafile <span style="color: #000000;">4</span>;
&nbsp;
Starting backup at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup <span style="color: #000000; font-weight: bold;">set</span>
channel ORA_DISK_1: specifying datafile<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">in</span> backup <span style="color: #000000; font-weight: bold;">set</span>
input datafile <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #007800;">number</span>=00004 <span style="color: #007800;">name</span>=<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>oradata<span style="color: #000000; font-weight: bold;">/</span>orcl<span style="color: #000000; font-weight: bold;">/</span>users01.dbf
channel ORA_DISK_1: starting piece <span style="color: #000000;">1</span> at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
channel ORA_DISK_1: finished piece <span style="color: #000000;">1</span> at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
piece <span style="color: #007800;">handle</span>=<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>fast_recovery_area<span style="color: #000000; font-weight: bold;">/</span>ORCL<span style="color: #000000; font-weight: bold;">/</span>backupset<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>_02_15<span style="color: #000000; font-weight: bold;">/</span>o1_mf_nnndf_TAG20130215T122853_8kw6zotn_.bkp <span style="color: #007800;">tag</span>=TAG20130215T122853 <span style="color: #007800;">comment</span>=NONE
channel ORA_DISK_1: backup <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #7a0874; font-weight: bold;">complete</span>, elapsed time: 00:00:01
Finished backup at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
&nbsp;
Starting Control File Autobackup at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
piece <span style="color: #007800;">handle</span>=<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>fast_recovery_area<span style="color: #000000; font-weight: bold;">/</span>ORCL<span style="color: #000000; font-weight: bold;">/</span>autobackup<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>_02_15<span style="color: #000000; font-weight: bold;">/</span>o1_mf_n_807452934_8kw6zqj6_.bkp <span style="color: #007800;">comment</span>=NONE
Finished Control File Autobackup at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span></pre></td></tr></table></div>

<p>To simulate the crash, shutdown the database, delete at OS level the datafile located at /u01/app/oracle/oradata/orcl/users01.dbf, startup the database that will complains for:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">ORA<span style="color: #66cc66;">-</span>01157: cannot identify<span style="color: #66cc66;">/</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOCK</span> data <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span> <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">-</span> see DBWR trace <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span>
ORA<span style="color: #66cc66;">-</span>01110: data <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span> <span style="color: #cc66cc;">4</span>: <span style="color: #ff0000;">'/u01/app/oracle/oradata/orcl/users01.dbf'</span></pre></td></tr></table></div>

<p>You can anyway start it with:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ALTER</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">DATABASE</span> datafile <span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">OFFLINE</span>;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">DATABASE</span> altered.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ALTER</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">DATABASE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">OPEN</span>;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">DATABASE</span> altered.</pre></td></tr></table></div>

<p>Then recover using <a href="http://blog.yannickjaquier.com/oracle/data-recovery-advisor-dra-and-health-monitor-by-examples.html" title="Data Recovery Advisor (DRA) and Health Monitor by examples">Data Recovery Advisor (DRA)</a> is as simple as:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">list failure <span style="color: #7a0874; font-weight: bold;">&#91;</span>detail<span style="color: #7a0874; font-weight: bold;">&#93;</span>
advise failure
repair failure</pre></td></tr></table></div>

<p>At the end, as you guess, the recover script generated by DRA is:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">   <span style="color: #666666; font-style: italic;"># restore and recover datafile</span>
   restore datafile <span style="color: #000000;">4</span>;
   recover datafile <span style="color: #000000;">4</span>;</pre></td></tr></table></div>

<p>You will then just need to issue under RMAN (or SQL by the way):</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">RMAN<span style="color: #000000; font-weight: bold;">&gt;</span> sql <span style="color: #ff0000;">'alter database datafile 4 online'</span>;</pre></td></tr></table></div>

<p>Or else you get:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">ORA<span style="color: #66cc66;">-</span>00376: <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span> <span style="color: #cc66cc;">4</span> cannot be read <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AT</span> this <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TIME</span>
ORA<span style="color: #66cc66;">-</span>01110: data <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span> <span style="color: #cc66cc;">4</span>: <span style="color: #ff0000;">'/u01/app/oracle/oradata/orcl/users01.dbf'</span></pre></td></tr></table></div>

<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Nologging_and_CTAS"><h1>Nologging and CTAS</h1></span>
<p><P>For the test case I create a table and an index both in nologging. I measure in parallel the redo size generated:</P>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SET</span> lines <span style="color: #cc66cc;">200</span> pages <span style="color: #cc66cc;">200</span>
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> name<span style="color: #66cc66;">,</span> a.<span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> v$sesstat a<span style="color: #66cc66;">,</span> v$sysstat b
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> b.statistic# <span style="color: #66cc66;">=</span> a.statistic#
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> b.name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'redo size'</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> a.sid <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> sid <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> v$mystat <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ROWNUM</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
NAME                                                                  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span>
<span style="color: #808080; font-style: italic;">---------------------------------------------------------------- ----------</span>
redo <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SIZE</span>                                                               <span style="color: #cc66cc;">664</span>
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">CREATE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> test1 nologging <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLESPACE</span> users <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AS</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_objects;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> created.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">CREATE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span> test1_idx_OWNER <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ON</span> test1<span style="color: #66cc66;">&#40;</span>owner<span style="color: #66cc66;">&#41;</span> nologging <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLESPACE</span> users;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span> created.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXEC</span> DBMS_STATS.GATHER_TABLE_STATS<span style="color: #66cc66;">&#40;</span>ownname <span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'YJAQUIER'</span><span style="color: #66cc66;">,</span> tabname <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">'TEST1'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
PL<span style="color: #66cc66;">/</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SQL</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">PROCEDURE</span> successfully completed.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> name<span style="color: #66cc66;">,</span> a.<span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> v$sesstat a<span style="color: #66cc66;">,</span> v$sysstat b
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> b.statistic# <span style="color: #66cc66;">=</span> a.statistic#
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> b.name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'redo size'</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> a.sid <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> sid <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> v$mystat <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ROWNUM</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
NAME                                                                  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span>
<span style="color: #808080; font-style: italic;">---------------------------------------------------------------- ----------</span>
redo <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SIZE</span>                                                            <span style="color: #cc66cc;">287668</span></pre></td></tr></table></div>

<p>Doing the same SQL block in LOGGING mode would generate instead 10,808,868 bytes of redo (37 times more !!).</p>
<p>Let&#8217;s simulate the crash as we have seen in preamble section and select on our test table. One important thing to note here is that table and index will <strong style="color: red;">still be valid</strong> after the recover even if by selecting them you will generate an error:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> yjaquier.test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> owner<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'YJAQUIER'</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> yjaquier.test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> owner<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'YJAQUIER'</span>
                       <span style="color: #66cc66;">*</span>
ERROR <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AT</span> line <span style="color: #cc66cc;">1</span>:
ORA<span style="color: #66cc66;">-</span>01578: ORACLE data block corrupted <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span> # <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">,</span> block # <span style="color: #cc66cc;">1595</span><span style="color: #66cc66;">&#41;</span>
ORA<span style="color: #66cc66;">-</span>01110: data <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span> <span style="color: #cc66cc;">4</span>: <span style="color: #ff0000;">'/u01/app/oracle/oradata/orcl/users01.dbf'</span>
ORA<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">26040</span>: Data block was loaded <span style="color: #993333; font-weight: bold; text-transform: uppercase;">USING</span> the NOLOGGING <span style="color: #993333; font-weight: bold; text-transform: uppercase;">OPTION</span>
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> SEGMENT_TYPE<span style="color: #66cc66;">,</span> OWNER <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">'.'</span> <span style="color: #66cc66;">||</span> SEGMENT_NAME
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> DBA_EXTENTS
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> FILE_ID <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> <span style="color: #cc66cc;">1595</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">BETWEEN</span> BLOCK_ID <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> BLOCK_ID<span style="color: #66cc66;">+</span>BLOCKS<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span>;
&nbsp;
SEGMENT_TYPE       OWNER<span style="color: #66cc66;">||</span><span style="color: #ff0000;">'.'</span><span style="color: #66cc66;">||</span>SEGMENT_NAME
<span style="color: #808080; font-style: italic;">------------------ ----------------------------------------------------------------------------------------------------------------</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span>              YJAQUIER.TEST1_IDX_OWNER
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> V$DATABASE_BLOCK_CORRUPTION;
&nbsp;
     <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span>#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
<span style="color: #808080; font-style: italic;">---------- ---------- ---------- ------------------ ---------</span>
         <span style="color: #cc66cc;">4</span>        <span style="color: #cc66cc;">168</span>          <span style="color: #cc66cc;">8</span>            <span style="color: #cc66cc;">2382810</span> NOLOGGING
         <span style="color: #cc66cc;">4</span>        <span style="color: #cc66cc;">177</span>         <span style="color: #cc66cc;">15</span>            <span style="color: #cc66cc;">2382837</span> NOLOGGING
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> table_name<span style="color: #66cc66;">,</span>status<span style="color: #66cc66;">,</span>logging <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_tables <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> table_name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'TEST1'</span>;
&nbsp;
TABLE_NAME                     STATUS   <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOG</span>
<span style="color: #808080; font-style: italic;">------------------------------ -------- ---</span>
TEST1                          VALID    NO
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> INDEX_NAME<span style="color: #66cc66;">,</span>status<span style="color: #66cc66;">,</span>LOGGING <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_indexes <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> table_name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'TEST1'</span>;
&nbsp;
INDEX_NAME                     STATUS   <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOG</span>
<span style="color: #808080; font-style: italic;">------------------------------ -------- ---</span>
TEST1_IDX_OWNER                VALID    NO</pre></td></tr></table></div>

<p>As only the index seems corrupted let&#8217;s drop it:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">DROP</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span> TEST1_IDX_OWNER;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span> dropped.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> owner<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'YJAQUIER'</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> owner<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'YJAQUIER'</span>
              <span style="color: #66cc66;">*</span>
ERROR <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AT</span> line <span style="color: #cc66cc;">1</span>:
ORA<span style="color: #66cc66;">-</span>01578: ORACLE data block corrupted <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span> # <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">,</span> block # <span style="color: #cc66cc;">171</span><span style="color: #66cc66;">&#41;</span>
ORA<span style="color: #66cc66;">-</span>01110: data <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FILE</span> <span style="color: #cc66cc;">4</span>: <span style="color: #ff0000;">'/u01/app/oracle/oradata/orcl/users01.dbf'</span>
ORA<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">26040</span>: Data block was loaded <span style="color: #993333; font-weight: bold; text-transform: uppercase;">USING</span> the NOLOGGING <span style="color: #993333; font-weight: bold; text-transform: uppercase;">OPTION</span>
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> SEGMENT_TYPE<span style="color: #66cc66;">,</span> OWNER <span style="color: #66cc66;">||</span> <span style="color: #ff0000;">'.'</span> <span style="color: #66cc66;">||</span> SEGMENT_NAME
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> DBA_EXTENTS
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> FILE_ID <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> <span style="color: #cc66cc;">171</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">BETWEEN</span> BLOCK_ID <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> BLOCK_ID<span style="color: #66cc66;">+</span>BLOCKS<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span>;
&nbsp;
SEGMENT_TYPE       OWNER<span style="color: #66cc66;">||</span><span style="color: #ff0000;">'.'</span><span style="color: #66cc66;">||</span>SEGMENT_NAME
<span style="color: #808080; font-style: italic;">------------------ ----------------------------------------------------------------------------------------------------------------</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span>              YJAQUIER.TEST1</pre></td></tr></table></div>

<p>Worst situation here the index <strong style="color: red;">and</strong> the table are corrupted. If not a big deal for the index it is an issue for the table if you are not in a DataWareHouse environment.</p>
<p>Remark<br />If you create the table in LOGGING and index in NOLOGGING then the index is obviously still corrupted but you <strong style="color: red;">can still access</strong> to table figures that are not corrupted.</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Nologging_and_insert_command"><h1>Nologging and insert command</h1></span>
<p>For INSERT command the test table I&#8217;m gonna use is the following:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">DROP</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> test1;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">CREATE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> test1<span style="color: #66cc66;">&#40;</span>id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span><span style="color: #66cc66;">,</span> descr <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VARCHAR2</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> NOLOGGING <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLESPACE</span> users;</pre></td></tr></table></div>

<p>To see that only direct-path INSERT are concerned by NOLOGGING mode, if you load this test table with below block I have already used in my <a href="http://blog.yannickjaquier.com/oracle/bind-variables-peeking-and-adaptive-cursor-sharing-acs.html" title="Bind variables peeking and Adaptive Cursor Sharing (ACS)">Adaptive Cursor Sharing (ACS)</a> post:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">DECLARE</span>
  i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
  nbrows <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">BEGIN</span>
  i:<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;
  nbrows:<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">50000</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXIT</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHEN</span> i<span style="color: #66cc66;">&gt;</span>nbrows;
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IF</span> <span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">THEN</span>
      <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INSERT</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUES</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">RPAD</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">49</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ELSE</span>
      <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INSERT</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUES</span><span style="color: #66cc66;">&#40;</span>nbrows<span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">RPAD</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">49</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IF</span>;
    i:<span style="color: #66cc66;">=</span>i<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">COMMIT</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span>;
<span style="color: #66cc66;">/</span></pre></td></tr></table></div>

<p>If we apply same opus operandi:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">CREATE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span> test1_idx_id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ON</span> test1<span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span> NOLOGGING <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLESPACE</span> users;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span> created.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXEC</span> DBMS_STATS.GATHER_TABLE_STATS<span style="color: #66cc66;">&#40;</span>ownname <span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'YJAQUIER'</span><span style="color: #66cc66;">,</span> tabname <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">'TEST1'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
PL<span style="color: #66cc66;">/</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SQL</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">PROCEDURE</span> successfully completed.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> name<span style="color: #66cc66;">,</span> a.<span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> v$sesstat a<span style="color: #66cc66;">,</span> v$sysstat b
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> b.statistic# <span style="color: #66cc66;">=</span> a.statistic#
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> b.name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'redo size'</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> a.sid <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> sid <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> v$mystat <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ROWNUM</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
NAME                                                                  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span>
<span style="color: #808080; font-style: italic;">---------------------------------------------------------------- ----------</span>
redo <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SIZE</span>                                                          <span style="color: #cc66cc;">15568652</span></pre></td></tr></table></div>

<p>This is proven by successful restore of the table (index still corrupted obviously)&#8230; To force index usage either use an hint (INDEX) or use id = 1 in your select statement on test1.</p>
<p>To do direct-path insert I replace my insert statement by:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">INSERT</span> <span style="">/*+ append */</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUES</span><span style="color: #66cc66;">&#40;</span>nbrows<span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">RPAD</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">49</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>But it didn&#8217;t work and then found in official documentation:</p>
<blockquote><p>
The APPEND hint is only supported with the subquery syntax of the INSERT statement, not the VALUES clause. If you specify the APPEND hint with the VALUES clause, it is ignored and conventional insert will be used. To use direct-path INSERT with the VALUES clause, refer to &#8220;APPEND_VALUES Hint&#8221;.
</p></blockquote>
<p>When replacing append hint by append_values hint and committing at the end of the block I got:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">ORA-<span style="color: #000000;">12838</span>: cannot read<span style="color: #000000; font-weight: bold;">/</span>modify an object after modifying it <span style="color: #000000; font-weight: bold;">in</span> parallel</pre></td></tr></table></div>

<p>Again it is in official documentation:</p>
<blockquote><p>
You cannot query or modify data inserted using direct-path INSERT immediately after the insert is complete. If you attempt to do so, an ORA-12838 error is generated. You must first issue a COMMIT statement before attempting to read or modify the newly-inserted data.
</p></blockquote>
<p>So had to use below <em>non-optimal</em> block:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">DECLARE</span>
  i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
  nbrows <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">BEGIN</span>
  i:<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;
  nbrows:<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">50000</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXIT</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHEN</span> i<span style="color: #66cc66;">&gt;</span>nbrows;
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IF</span> <span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">THEN</span>
      <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INSERT</span> <span style="">/*+ append_values */</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUES</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">RPAD</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">49</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #993333; font-weight: bold; text-transform: uppercase;">COMMIT</span>;
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ELSE</span>
      <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INSERT</span> <span style="">/*+ append_values */</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUES</span><span style="color: #66cc66;">&#40;</span>nbrows<span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">RPAD</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">49</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #993333; font-weight: bold; text-transform: uppercase;">COMMIT</span>;
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IF</span>;
    i:<span style="color: #66cc66;">=</span>i<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span>;
<span style="color: #66cc66;">/</span></pre></td></tr></table></div>

<p>Execution time was much longer (19 minutes instead of 13 seconds) and number of extents moved from 19 (4 MB) to 121 (400 MB) in my local autoallocate tablespace.</p>
<p>If we perform same commands and measure redo size:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">CREATE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span> test1_idx_id <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ON</span> test1<span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span> NOLOGGING <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLESPACE</span> users;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">INDEX</span> created.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">EXEC</span> DBMS_STATS.GATHER_TABLE_STATS<span style="color: #66cc66;">&#40;</span>ownname <span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'YJAQUIER'</span><span style="color: #66cc66;">,</span> tabname <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">'TEST1'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
PL<span style="color: #66cc66;">/</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SQL</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">PROCEDURE</span> successfully completed.
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> name<span style="color: #66cc66;">,</span> a.<span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> v$sesstat a<span style="color: #66cc66;">,</span> v$sysstat b
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> b.statistic# <span style="color: #66cc66;">=</span> a.statistic#
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> b.name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'redo size'</span>
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">AND</span> a.sid <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> sid <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> v$mystat <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">ROWNUM</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
NAME                                                                  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUE</span>
<span style="color: #808080; font-style: italic;">---------------------------------------------------------------- ----------</span>
redo <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SIZE</span>                                                          <span style="color: #cc66cc;">83720616</span></pre></td></tr></table></div>

<p>Redo size generated is 5 times greater !! Which is exactly the opposite of what we want. I would say it is worst of both world  as we have more redo and table and index are not recoverable&#8230;</p>
<p>There is apparently a bug with this <strong>append_values</strong> 11gR2 new hint (see references) with no clear solution so far&#8230; Also few references on Internet on this but in <a href="http://www.amazon.com/Expert-PL-SQL-Practices-Developers/dp/1430234857">Expert PL/SQL Practices: for Oracle Developers and DBAs</a> book they advise to use FORALL PL/SQL command when working with append_values hint so created the alternative PL/SQL block:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #993333; font-weight: bold; text-transform: uppercase;">DECLARE</span>
  i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
  nbrows <span style="color: #993333; font-weight: bold; text-transform: uppercase;">NUMBER</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TYPE</span> type1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IS</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">OF</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VARCHAR2</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span>;
  array1 type1 :<span style="color: #66cc66;">=</span> type1<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">BEGIN</span>
  nbrows:<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">50000</span>;
&nbsp;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FOR</span> i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IN</span> <span style="color: #cc66cc;">1</span>..nbrows <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>
    array1.extend;
    array1<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>:<span style="color: #66cc66;">=</span><span style="color: #993333; font-weight: bold; text-transform: uppercase;">RPAD</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">49</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">LOOP</span>;
&nbsp;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INSERT</span> <span style="">/*+ append_values */</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUES</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span>array1<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">COMMIT</span>;
&nbsp;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FORALL</span> i <span style="color: #993333; font-weight: bold; text-transform: uppercase;">IN</span> <span style="color: #cc66cc;">2</span>..array1.<span style="color: #993333; font-weight: bold; text-transform: uppercase;">COUNT</span>
    <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INSERT</span> <span style="">/*+ append_values */</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">INTO</span> test1 <span style="color: #993333; font-weight: bold; text-transform: uppercase;">VALUES</span> <span style="color: #66cc66;">&#40;</span>nbrows<span style="color: #66cc66;">,</span>array1<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <span style="color: #993333; font-weight: bold; text-transform: uppercase;">COMMIT</span>;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">END</span>;
<span style="color: #66cc66;">/</span></pre></td></tr></table></div>

<p>Execution time moved to 4 seconds and redo generated is equal to 384 KB so clearly as expected (smaller execution time and less redo generated). Table and index are still corrupted after media recovery but this was planned&#8230;</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Tablespaces_logging_attributes"><h1>Tablespaces logging attributes</h1></span>
<p>There are two logging attribute for a tablespace, the default logging mode for newly created object (if you change it, it does not affect already created objects) and the force logging mode (can also be specified at database level, that has preference over the one set at tablespace level) for generation of redo information even if users specify NOLOGGING in supported NOLOGGING operations:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> TABLESPACE_NAME<span style="color: #66cc66;">,</span>LOGGING<span style="color: #66cc66;">,</span>FORCE_LOGGING <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_tablespaces <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WHERE</span> TABLESPACE_NAME<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'USERS'</span>;
&nbsp;
TABLESPACE_NAME                LOGGING   <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FOR</span>
<span style="color: #808080; font-style: italic;">------------------------------ --------- ---</span>
USERS                          LOGGING   NO</pre></td></tr></table></div>

<p>This could be used if you want to be 100% sure that you media recovery will not let objects with corrupted blocks&#8230;</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="RMAN_and_nologging_operations"><h1>RMAN and nologging operations</h1></span>
<p>RMAN has a very interesting reporting function for nologging operations called <strong>report unrecoverable</strong>. To test it I empty my users tablespace and backup it:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">RMAN<span style="color: #000000; font-weight: bold;">&gt;</span> backup datafile <span style="color: #000000;">4</span>;
&nbsp;
Starting backup at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup <span style="color: #000000; font-weight: bold;">set</span>
channel ORA_DISK_1: specifying datafile<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">in</span> backup <span style="color: #000000; font-weight: bold;">set</span>
input datafile <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #007800;">number</span>=00004 <span style="color: #007800;">name</span>=<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>oradata<span style="color: #000000; font-weight: bold;">/</span>orcl<span style="color: #000000; font-weight: bold;">/</span>users01.dbf
channel ORA_DISK_1: starting piece <span style="color: #000000;">1</span> at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
channel ORA_DISK_1: finished piece <span style="color: #000000;">1</span> at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
piece <span style="color: #007800;">handle</span>=<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>fast_recovery_area<span style="color: #000000; font-weight: bold;">/</span>ORCL<span style="color: #000000; font-weight: bold;">/</span>backupset<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>_02_15<span style="color: #000000; font-weight: bold;">/</span>o1_mf_nnndf_TAG20130215T175913_8kwtc1r9_.bkp <span style="color: #007800;">tag</span>=TAG20130215T175913 <span style="color: #007800;">comment</span>=NONE
channel ORA_DISK_1: backup <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #7a0874; font-weight: bold;">complete</span>, elapsed time: 00:00:01
Finished backup at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
&nbsp;
Starting Control File Autobackup at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
piece <span style="color: #007800;">handle</span>=<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>fast_recovery_area<span style="color: #000000; font-weight: bold;">/</span>ORCL<span style="color: #000000; font-weight: bold;">/</span>autobackup<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>_02_15<span style="color: #000000; font-weight: bold;">/</span>o1_mf_n_807472754_8kwtc3bo_.bkp <span style="color: #007800;">comment</span>=NONE
Finished Control File Autobackup at <span style="color: #000000;">15</span>-FEB-<span style="color: #000000;">13</span>
&nbsp;
RMAN<span style="color: #000000; font-weight: bold;">&gt;</span> report unrecoverable;
&nbsp;
Report of files that need backup due to unrecoverable operations
File Type of Backup Required Name
<span style="color: #660033;">----</span> <span style="color: #660033;">-----------------------</span> <span style="color: #660033;">-----------------------------------</span></pre></td></tr></table></div>

<p>If I create a table with logging attribute:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">CREATE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> test1 logging <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLESPACE</span> users <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AS</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_objects;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> created.</pre></td></tr></table></div>

<p>Still no issue:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">RMAN<span style="color: #000000; font-weight: bold;">&gt;</span> report unrecoverable;
&nbsp;
Report of files that need backup due to unrecoverable operations
File Type of Backup Required Name
<span style="color: #660033;">----</span> <span style="color: #660033;">-----------------------</span> <span style="color: #660033;">-----------------------------------</span></pre></td></tr></table></div>

<p>If I now create a table with nologging attribute:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">CREATE</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> test2 nologging <span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLESPACE</span> users <span style="color: #993333; font-weight: bold; text-transform: uppercase;">AS</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold; text-transform: uppercase;">FROM</span> dba_objects;
&nbsp;
<span style="color: #993333; font-weight: bold; text-transform: uppercase;">TABLE</span> created.</pre></td></tr></table></div>

<p>Then RMAN is able to track it:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">RMAN<span style="color: #000000; font-weight: bold;">&gt;</span> report unrecoverable;
&nbsp;
using target database control <span style="color: #c20cb9; font-weight: bold;">file</span> instead of recovery catalog
Report of files that need backup due to unrecoverable operations
File Type of Backup Required Name
<span style="color: #660033;">----</span> <span style="color: #660033;">-----------------------</span> <span style="color: #660033;">-----------------------------------</span>
<span style="color: #000000;">4</span>    full or incremental     <span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>oracle<span style="color: #000000; font-weight: bold;">/</span>oradata<span style="color: #000000; font-weight: bold;">/</span>orcl<span style="color: #000000; font-weight: bold;">/</span>users01.dbf</pre></td></tr></table></div>

<p>At this stage you know that you must perform another backup of users01.dbf datafile to be 100% sure your media recovery will not let objects in an unrecoverable state&#8230;</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="References"><h1>References</h1></span>
<ul>
<li><a href="http://docs.oracle.com/cd/E11882_01/server.112/e26088/clauses005.htm#CJAHABGF">logging_clause</a></li>
<li><a href="http://docs.oracle.com/cd/E11882_01/server.112/e17120/tables004.htm#ADMIN01509">Improving INSERT Performance with Direct-Path INSERT</a></li>
<li>APPEND Hint (Direct-Path) Insert with Values Causes Excessive Space Usage on 11G [ID 842374.1]</li>
</ul>
<!-- Start Shareaholic Recommendations Automatic --><!-- End Shareaholic Recommendations Automatic -->]]></content:encoded>
			<wfw:commentRss>http://blog.yannickjaquier.com/oracle/media-recovery-with-nologging-tables.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tmpfs vs Ramfs vs (Transparent) Huge Pages</title>
		<link>http://blog.yannickjaquier.com/linux/tmpfs-vs-ramfs-vs-transparent-huge-pages.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tmpfs-vs-ramfs-vs-transparent-huge-pages</link>
		<comments>http://blog.yannickjaquier.com/linux/tmpfs-vs-ramfs-vs-transparent-huge-pages.html#comments</comments>
		<pubDate>Thu, 28 Feb 2013 07:00:01 +0000</pubDate>
		<dc:creator>Yannick</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Automatic Memory Management (AMM)]]></category>
		<category><![CDATA[Automatic Shared Memory Management (ASMM)]]></category>
		<category><![CDATA[HugePages]]></category>
		<category><![CDATA[Virtual Memory]]></category>

		<guid isPermaLink="false">http://blog.yannickjaquier.com/?p=1991</guid>
		<description><![CDATA[Preamble What are the possible configuration for Automatic Shared Memory Management (ASMM) and Automatic Memory Management (AMM) with ramfs, tmpfs and (Transparent) Huge Pages. Some configurations are simply not supported while for some you have to choose between flexibility and performance&#8230; Testing has been done using Oracle Linux Server release 6.3 (Kernel 2.6.39-300.26.1.el6uek.x86_64) and Oracle [...]]]></description>
				<content:encoded><![CDATA[<div class='toc wptoc'>
<h2>Table Of Contents</h2>
<ol class='toc-odd level-1'>
	<li>
		<a href="#Preamble">Preamble</a>
	</li>
	<li>
		<a href="#Tmpfs">Tmpfs</a>
	</li>
	<li>
		<a href="#Ramfs">Ramfs</a>
	</li>
	<li>
		<a href="#Huge_Pages">Huge Pages</a>
	</li>
	<li>
		<a href="#Transparent_Huge_Pages_THP">Transparent Huge Pages (THP)</a>
	</li>
	<li>
		<a href="#References">References</a>
	</li>
</ol>
</div>
<div class='wptoc-end'>&nbsp;</div>
<p><span id="more-1991"></span></p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Preamble"><h1>Preamble</h1></span>
<p>What are the possible configuration for Automatic Shared Memory Management (ASMM) and Automatic Memory Management (AMM) with ramfs, tmpfs and (Transparent) Huge Pages. Some configurations are simply not supported while for some you have to choose between flexibility and performance&#8230;</p>
<p>Testing has been done using Oracle Linux Server release 6.3 (Kernel 2.6.39-300.26.1.el6uek.x86_64) and Oracle 11.2.0.3.</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Tmpfs"><h1>Tmpfs</h1></span>
<p>Previously known as shmfs, <a href="http://en.wikipedia.org/wiki/Tmpfs" title="tmpfs">tmpfs</a> is created by default when installing most Linux distribution:</></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># grep shm /etc/fstab</span>
tmpfs                           <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm                                tmpfs   defaults        <span style="color: #000000;">0</span> <span style="color: #000000;">0</span></pre></td></tr></table></div>

<p>By default 50% of server physical memory will be <em>*used*</em>, in fact not really used because pages can be swap out. This is pseudo File System to configure if you want to use Automatic Memory Management (AMM) feature i.e. using <strong>memory_target</strong> and <strong>memory_max_target</strong> initialization parameters.</p>
<p>This implementation is quite common but not at all recommended, even by Oracle, when having a server with plenty of memory. In such scenario managing memory page table can be quite time consuming:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># grep -i pagetables /proc/meminfo</span>
PageTables:        <span style="color: #000000;">12500</span> kB</pre></td></tr></table></div>

<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Ramfs"><h1>Ramfs</h1></span>
<p>The main differences, well sum up by The Geek Stuff (see references), are:</p>
<table>
<tr>
<th>Experimentation</th>
<th>Tmpfs</th>
<th>Ramfs</th>
</tr>
<tr>
<td>Fill maximum space and continue writing</td>
<td>Will display error</td>
<td>Will continue writing</td>
</tr>
<tr>
<td>Fixed Size</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Uses Swap</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Volatile Storage</td>
<td>Yes</td>
<td>Yes</td>
</tr>
</table>
<p>So on the paper it looks great:</p>
<ul>
<li>Does <strong>not use swap</strong> !</li>
<li>Can fill beyond limit but not an issue if you are careful, in any case we are talking of Oracle memory allocation so you control it !</li>
</ul>
<p>To configure it use the following:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># grep shm /etc/fstab</span>
ramfs                   <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm                ramfs   defaults        <span style="color: #000000;">0</span> <span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># df -P /dev/shm</span>
Filesystem         <span style="color: #000000;">1024</span>-blocks      Used Available Capacity Mounted on
ramfs                   <span style="color: #000000;">510352</span>       <span style="color: #000000;">112</span>    <span style="color: #000000;">510240</span>       <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm</pre></td></tr></table></div>

<p>The database is starting well and use /dev/shm pseudo-File System correctly:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 orcl<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># df -P /dev/shm</span>
Filesystem         <span style="color: #000000;">1024</span>-blocks      Used Available Capacity Mounted on
ramfs                   <span style="color: #000000;">510352</span>    <span style="color: #000000;">192540</span>    <span style="color: #000000;">317812</span>      <span style="color: #000000;">38</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm</pre></td></tr></table></div>

<p>Unfortunately as it is explained in MOS note 749851.1 it is <strong style="color: red;">not supported</strong>:</p>
<blockquote><p>
Please also note that ramfs (instead of tmpfs mount over /dev/shm) is not supported for AMM at all. With AMM the Oracle database needs to grow and reduce the size of SGA dynamically. This is not possible with ramfs where it possible and supported with tmpfs (which is the default for the OS installation).
</p></blockquote>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Huge_Pages"><h1>Huge Pages</h1></span>
<p>As we have seen in this <a href="http://blog.yannickjaquier.com/linux/linux-hugepages-and-virtual-memory-vm-tuning.html" title="Linux HugePages and virtual memory (VM) tuning">blog post</a> Huge Pages is an answer to swapping. But unfortunately as clearly mentioned in documentation available at (install kernel-doc package):</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ll /usr/share/doc/kernel-doc-2.6.39/Documentation/vm/hugetlbpage.txt</span>
<span style="color: #660033;">-r--r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">15156</span> Jan  <span style="color: #000000;">4</span> 03:06 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>kernel-doc-2.6.39<span style="color: #000000; font-weight: bold;">/</span>Documentation<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>hugetlbpage.txt</pre></td></tr></table></div>

<p>It is only for shared memory (so SGA and not PGA):</p>
<blockquote><p>
Users can use the huge page support in Linux kernel by either using the mmap system call or standard SYSV shared memory system calls (shmget, shmat).
</p></blockquote>
<p>The documentation also mentioned its usage using mmap method and so allocating Huge Pages in a filesystem. Why not using it with AMM ? To test it I mounted a filesystem of <strong>hugetlbfs</strong> type giving privileges to my oracle Unix account.</p>
<p>Kernel settings:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Huge Pages</span>
vm.nr_hugepages = <span style="color: #000000;">101</span>
vm.hugetlb_shm_group = <span style="color: #000000;">500</span></pre></td></tr></table></div>

<p>Oracle settings:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*</span>.memory_target=200m
<span style="color: #000000; font-weight: bold;">*</span>.pre_page_sga=TRUE
<span style="color: #000000; font-weight: bold;">*</span>.use_large_pages=<span style="color: #ff0000;">'ONLY'</span></pre></td></tr></table></div>

<p>To mount the filesystem:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>oracle<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">id</span>
<span style="color: #007800;">uid</span>=<span style="color: #000000;">501</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>oracle<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">gid</span>=<span style="color: #000000;">500</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>dba<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">groups</span>=<span style="color: #000000;">500</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>dba<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># mount -t hugetlbfs -o uid=501,gid=500,size=202M none /dev/shm</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># df -P /dev/shm</span>
Filesystem         <span style="color: #000000;">1024</span>-blocks      Used Available Capacity Mounted on
none                    <span style="color: #000000;">206848</span>         <span style="color: #000000;">0</span>    <span style="color: #000000;">206848</span>       <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm</pre></td></tr></table></div>

<p>But unfortunately Oracle is not starting:>/p></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracel11" style="font-family:monospace;">SQL&gt; startup
ORA-27102: out of memory
Linux-x86_64 Error: 12: Cannot allocate memory
Additional information: 1
Additional information: 1081350
Additional information: 14</pre></td></tr></table></div>

<p>I tried to manually create and fill a dummy file, but same error:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="oracle11" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>oracle@server1 ~<span style="color: #66cc66;">&#93;</span>$ cd <span style="color: #66cc66;">/</span>dev<span style="color: #66cc66;">/</span>shm
<span style="color: #66cc66;">&#91;</span>oracle@server1 shm<span style="color: #66cc66;">&#93;</span>$ touch test1
<span style="color: #66cc66;">&#91;</span>oracle@server1 shm<span style="color: #66cc66;">&#93;</span>$ ll
total <span style="color: #cc66cc;">0</span>
<span style="color: #66cc66;">-</span>rw<span style="color: #66cc66;">-</span>r<span style="color: #808080; font-style: italic;">--r-- 1 oracle dba 0 Feb  5 12:09 test1</span>
<span style="color: #66cc66;">&#91;</span>oracle@server1 shm<span style="color: #66cc66;">&#93;</span>$ echo test1 <span style="color: #66cc66;">&gt;</span> test1
<span style="color: #66cc66;">-</span>bash: echo: <span style="color: #993333; font-weight: bold; text-transform: uppercase;">WRITE</span> error: Invalid argument</pre></td></tr></table></div>

<p>And finally found in Kernel documentation (!!):</p>
<blockquote><p>
While read system calls are supported on files that reside on hugetlb file systems, write system calls are not.
</p></blockquote>
<p>Then I&#8217;m wondering the real usage of this mmap method using Huge Pages&#8230;</p>
<p>There are few posts about using <strong>_realfree_heap_pagesize_hint</strong> initialization parameter to make PGA use Huge Pages but it does not work on Linux&#8230;</p>
<p>Remark:<br />Huge Pages size can also be obtained using:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 orcl<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># hugeadm --page-sizes-all</span>
<span style="color: #000000;">2097152</span></pre></td></tr></table></div>

<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="Transparent_Huge_Pages_THP"><h1>Transparent Huge Pages (THP)</h1></span>
<p>Official documentation is available at:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ll /usr/share/doc/kernel-doc-2.6.39/Documentation/vm/transhuge.txt</span>
<span style="color: #660033;">-r--r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">14310</span> Jan  <span style="color: #000000;">4</span> 03:06 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>kernel-doc-2.6.39<span style="color: #000000; font-weight: bold;">/</span>Documentation<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>transhuge.txt</pre></td></tr></table></div>

<p>As its name stand for it is Huge Pages benefit:</p>
<ul>
<li>Bigger pages (2MB on Linux) so 512 times less ping-pong with kernel for page fault</li>
<li>Faster and reduced Translation Lookaside Buffer (TLB) misses and reduced kernel PageSize</li>
</ul>
<p>And this transparently for every applications without the need to allocate them in advance (no server reboot). The only drawback I see versus standard Huge Pages is that they can be swap out (as 4KB pages) even if RedHat state it is an added value, at least not for Oracle databases.</p>
<p>You can also see in documentation some interesting insights for future:</p>
<blockquote><p>
Currently it only works for anonymous memory mappings but in the future it can expand over the pagecache layer starting with tmpfs.
</p></blockquote>
<p>To activate THP set below file to always or madvise:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cat /sys/kernel/mm/transparent_hugepage/enabled</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>always<span style="color: #7a0874; font-weight: bold;">&#93;</span> madvise never</pre></td></tr></table></div>

<p>This will start <strong>khugepaged</strong> daemon:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ps -ef | grep khugepaged | grep -v grep</span>
root        <span style="color: #000000;">26</span>     <span style="color: #000000;">2</span>  <span style="color: #000000;">0</span> Feb04 ?        00:00:02 <span style="color: #7a0874; font-weight: bold;">&#91;</span>khugepaged<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></td></tr></table></div>

<p>Memory automatic defragmentation to allocate HugePages is controlled by:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cat /sys/kernel/mm/transparent_hugepage/defrag</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>always<span style="color: #7a0874; font-weight: bold;">&#93;</span> madvise never</pre></td></tr></table></div>

<p>You can, as well, find many khugepaged parameters in <strong>/sys/kernel/mm/transparent_hugepage/khugepaged</strong> directory.</p>
<p>RedHat claim 10% improvement using THP, but how to monitor THP usage ?</p>
<p>For testing I have used below settings, and measured memory allocation before and after starting an Oracle database:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*</span>.sga_target=150m
<span style="color: #000000; font-weight: bold;">*</span>.pga_aggregate_target=100m
<span style="color: #000000; font-weight: bold;">*</span>.pre_page_sga=TRUE
<span style="color: #000000; font-weight: bold;">*</span>.use_large_pages=<span style="color: #ff0000;">'ONLY'</span></pre></td></tr></table></div>

<p>For Linux:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># sysctl -w vm.nr_hugepages=77</span>
vm.nr_hugepages = <span style="color: #000000;">77</span></pre></td></tr></table></div>

<p>Before:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># grep Ano /proc/meminfo</span>
AnonPages:         <span style="color: #000000;">24140</span> kB
AnonHugePages:      <span style="color: #000000;">6144</span> kB
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># egrep 'trans|thp' /proc/vmstat</span>
nr_anon_transparent_hugepages <span style="color: #000000;">3</span>
thp_fault_alloc <span style="color: #000000;">3765</span>
thp_fault_fallback <span style="color: #000000;">201</span>
thp_collapse_alloc <span style="color: #000000;">805</span>
thp_collapse_alloc_failed <span style="color: #000000;">14</span>
thp_split <span style="color: #000000;">167</span></pre></td></tr></table></div>

<p>After:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># grep Ano /proc/meminfo</span>
AnonPages:        <span style="color: #000000;">426380</span> kB
AnonHugePages:    <span style="color: #000000;">350208</span> kB
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># egrep 'trans|thp' /proc/vmstat</span>
nr_anon_transparent_hugepages <span style="color: #000000;">173</span>
thp_fault_alloc <span style="color: #000000;">3996</span>
thp_fault_fallback <span style="color: #000000;">233</span>
thp_collapse_alloc <span style="color: #000000;">805</span>
thp_collapse_alloc_failed <span style="color: #000000;">14</span>
thp_split <span style="color: #000000;">167</span></pre></td></tr></table></div>

<p>So yes it is used but it&#8217;s difficult to know what is really using it (transparent you said ?), here I know because the Oracle database is the only thing that has been started&#8230; On top of this mapping what has been set at Oracle level (PGA = 100MB) and what you see at OS level is not possible&#8230;</p>
<p><!-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------></p>
<span id="References"><h1>References</h1></span>
<ul>
<li><a href="http://www.thegeekstuff.com/2008/11/overview-of-ramfs-and-tmpfs-on-linux/">Overview of RAMFS and TMPFS on Linux</a></li>
<li>Use and Impact of tmpfs and ramfs for Applications Running on a Compute Node [ID 1394580.1]</li>
<li>HugePages and Oracle Database 11g Automatic Memory Management (AMM) on Linux [ID 749851.1]</li>
<li><a href="http://dsstos.blogspot.ch/2008/10/realfreeheappagesizehint-assessing.html">_realfree_heap_pagesize_hint &#8211; Assessing the impact on Solaris and Linux</a></li>
<li><a href="https://access.redhat.com/knowledge/solutions/46111">How to use and monitor transparent hugepages in Red Hat Enterprise Linux 6?</a></li>
</ul>
<!-- Start Shareaholic Recommendations Automatic --><!-- End Shareaholic Recommendations Automatic -->]]></content:encoded>
			<wfw:commentRss>http://blog.yannickjaquier.com/linux/tmpfs-vs-ramfs-vs-transparent-huge-pages.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Have you recently taken a backup of your SQL Server databases ?</title>
		<link>http://blog.yannickjaquier.com/sql-server/have-you-recently-taken-a-backup-of-your-sql-server-databases.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=have-you-recently-taken-a-backup-of-your-sql-server-databases</link>
		<comments>http://blog.yannickjaquier.com/sql-server/have-you-recently-taken-a-backup-of-your-sql-server-databases.html#comments</comments>
		<pubDate>Tue, 12 Feb 2013 10:44:41 +0000</pubDate>
		<dc:creator>Yannick</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[Backup]]></category>

		<guid isPermaLink="false">http://blog.yannickjaquier.com/?p=2010</guid>
		<description><![CDATA[Available databases backup Have you recently taken a backup of your SQL Server databases ? Where I work we do full database backup on disk with T-SQL BACKUP command. Those backup files are then put on tape using Tivoli Storage Manager (TSM). The below T-SQL will list backups that have been taken, or not (backup_start_date [...]]]></description>
				<content:encoded><![CDATA[<div class='toc wptoc'>
<h2>Table Of Contents</h2>
<ol class='toc-odd level-1'>
	<li>
		<a href="#Available_databases_backup">Available databases backup</a>
	</li>
	<li>
		<a href="#References">References</a>
	</li>
</ol>
</div>
<div class='wptoc-end'>&nbsp;</div>
<p><span id="more-2010"></span></p>
<p><!-- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --></p>
<span id="Available_databases_backup"><h1>Available databases backup</h1></span>
<p>Have you recently taken a backup of your SQL Server databases ? Where I work we do full database backup on disk with T-SQL BACKUP command. Those backup files are then put on tape using Tivoli Storage Manager (TSM).</p>
<p>The below T-SQL will list backups that have been taken, or not (backup_start_date column will be NULL), for all your databases (outer join) within the last 10 days:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span>
  e.<span style="color: #202020;">name</span> <span style="color: #0000FF;">AS</span> database_name,
  d.<span style="color: #202020;">backup_start_date</span>,
  d.<span style="color: #202020;">backup_finish_date</span>,
  <span style="color: #FF00FF;">DATEDIFF</span><span style="color: #808080;">&#40;</span>mi,d.<span style="color: #202020;">backup_start_date</span>,d.<span style="color: #202020;">backup_finish_date</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> <span style="color: #FF0000;">&quot;backup duration (mi)&quot;</span>,
  d.<span style="color: #202020;">name</span>,
  d.<span style="color: #202020;">physical_device_name</span>,
  <span style="color: #0000FF;">CAST</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">ROUND</span><span style="color: #808080;">&#40;</span>d.<span style="color: #202020;">backup_size</span><span style="color: #808080;">/</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1024</span><span style="color: #808080;">*</span><span style="color: #000;">1024</span><span style="color: #808080;">&#41;</span>,<span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">INT</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> <span style="color: #FF0000;">&quot;backup size (MB)&quot;</span>,
  d.<span style="color: #202020;">is_compressed</span>,
  d.<span style="color: #202020;">recovery_model</span>
<span style="color: #0000FF;">FROM</span>
  <span style="color: #808080;">&#40;</span>
    <span style="color: #0000FF;">SELECT</span>
      a.<span style="color: #202020;">backup_set_id</span>,
      a.<span style="color: #202020;">name</span>,
      a.<span style="color: #202020;">backup_start_date</span>,
      a.<span style="color: #202020;">backup_finish_date</span>,
      a.<span style="color: #202020;">backup_size</span>,
      a.<span style="color: #202020;">database_name</span>,
      a.<span style="color: #202020;">recovery_model</span>,
      b.<span style="color: #202020;">is_compressed</span>,
      c.<span style="color: #202020;">physical_device_name</span>
    <span style="color: #0000FF;">FROM</span>
      msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">backupset</span> a,
      msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">backupmediaset</span> b,
      msdb.<span style="color: #202020;">dbo</span>.<span style="color: #202020;">backupmediafamily</span> c
    <span style="color: #0000FF;">WHERE</span> a.<span style="color: #202020;">media_set_id</span> <span style="color: #808080;">=</span> b.<span style="color: #202020;">media_set_id</span>
    <span style="color: #808080;">AND</span> b.<span style="color: #202020;">media_set_id</span> <span style="color: #808080;">=</span> c.<span style="color: #202020;">media_set_id</span>
    <span style="color: #808080;">AND</span> a.<span style="color: #202020;">type</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">'D'</span>
    <span style="color: #808080;">AND</span> a.<span style="color: #202020;">backup_start_date</span> <span style="color: #808080;">&gt;</span> <span style="color: #FF00FF;">GETDATE</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">-</span><span style="color: #000;">10</span>
  <span style="color: #808080;">&#41;</span>
  d
<span style="color: #0000FF;">RIGHT</span> <span style="color: #808080;">OUTER</span> <span style="color: #808080;">JOIN</span> sys.<span style="color: #202020;">databases</span> e
<span style="color: #0000FF;">ON</span> d.<span style="color: #202020;">database_name</span> <span style="color: #808080;">=</span> e.<span style="color: #202020;">name</span>
<span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> d.<span style="color: #202020;">backup_set_id</span> <span style="color: #0000FF;">DESC</span>;</pre></td></tr></table></div>

<p>Where type can take below value:</p>
<blockquote><p>
Backup type. Can be:<br />
D = Database<br />
I = Differential database<br />
L = Log<br />
F = File or filegroup<br />
G =Differential file<br />
P = Partial<br />
Q = Differential partial<br />
Can be NULL.
</p></blockquote>
<p><!-- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --></p>
<span id="References"><h1>References</h1></span>
<ul>
<li><a href="http://msdn.microsoft.com/fr-fr/library/ms186299.aspx">backupset (Transact-SQL)</a></li>
</ul>
<!-- Start Shareaholic Recommendations Automatic --><!-- End Shareaholic Recommendations Automatic -->]]></content:encoded>
			<wfw:commentRss>http://blog.yannickjaquier.com/sql-server/have-you-recently-taken-a-backup-of-your-sql-server-databases.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
