<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Iordan Iotzov&#039;s DBA blog</title>
	<atom:link href="http://iiotzov.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://iiotzov.wordpress.com</link>
	<description>The opinions here may not necessarily reflect that of my employers - both past and present. The comments left by the reviewers are theirs alone and may not reflect my opinion. None of the advice is warranted to be free of errors and omissions. Please use at your own risk and after thorough testing in your environment.</description>
	<lastBuildDate>Thu, 23 May 2013 13:23:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='iiotzov.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Iordan Iotzov&#039;s DBA blog</title>
		<link>http://iiotzov.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://iiotzov.wordpress.com/osd.xml" title="Iordan Iotzov&#039;s DBA blog" />
	<atom:link rel='hub' href='http://iiotzov.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Measuring the Benefits of Database Virtualization/Thin Provisioning Solutions</title>
		<link>http://iiotzov.wordpress.com/2013/05/14/measuring-the-benefits-of-database-virtualizationthin-provisioning-solutions/</link>
		<comments>http://iiotzov.wordpress.com/2013/05/14/measuring-the-benefits-of-database-virtualizationthin-provisioning-solutions/#comments</comments>
		<pubDate>Tue, 14 May 2013 18:57:57 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Resource Management]]></category>
		<category><![CDATA[Database Virtualization Oracle]]></category>
		<category><![CDATA[dbv HIGH_SCN]]></category>
		<category><![CDATA[HIGH_SCN]]></category>
		<category><![CDATA[Thin Provisioning Oracle]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=409</guid>
		<description><![CDATA[Overview Database virtualization and thin provisioning are new and powerful ways to share/reuse storage among non-production database copies. Solutions for reducing the disk footprint of non-production Oracle databases range from complete database virtualization (Delphix, etc), to solutions build around storage vendor’s features (EMC,NetApps, etc), to purely software solutions (cloneDB, etc). Sharing read-only tablespaces – a [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=409&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><strong>Overview</strong></p>
<p>Database virtualization and thin provisioning are new and powerful ways to share/reuse storage among non-production database copies.</p>
<p>Solutions for reducing the disk footprint of non-production Oracle databases range from complete database virtualization (Delphix, etc), to solutions build around storage vendor’s features (EMC,NetApps, etc), to purely software solutions (cloneDB, etc).</p>
<p>Sharing read-only tablespaces – a “poor man’s” database virtualization &#8211; is less known approach for saving disk space and improving refresh times in non-production environments. Here is a link to the presentation I did at NYOUG (2012) about this topic.</p>
<p><strong>What are we measuring and why?</strong></p>
<p>In general, most solutions are quite effective, both in terms of storage and refresh time, in delivering a copy of the production database.</p>
<p>Once the copy is delivered, it is open for users and batch jobs, so it starts changing. Those changes belong to the new database and therefore cannot be shared with the other non-production databases. That means that they consume &#8220;real&#8221; disk space. The more DB changes since refresh, the lower the benefits of the DB virtualization/thin provisioning solution.</p>
<p>Measuring the amount of change after a refresh is important in understanding how much disk space would be needed for the non-production Oracle environments after DB virtualization/thin provisioning is in place. The number is essential in computing ROI of the project.</p>
<p><strong>How are we measuring it?</strong></p>
<p>One way to measure the change is to run an incremental RMAN backup and see how big the resulting backup file(s) is. In many cases, however, that is not doable.</p>
<p>The method described here works only on 11gR2. It only requires the SCN of the DB at the time of refresh.</p>
<p>The information can be find in V$DATABASE (RESETLOG_CHANGE#) for databases created by RMAN DUPLICATE.</p>
<p>If the data was transferred with DataPump, or other similar method, a suitable SCN can be found in V$ARCHIVED_LOG (FIRST_CHANGE#, NEXT_CHANGE#).</p>
<p>The new DBVerify feature allows us to utilize HIGH_SCN parameter to find out how many blocks where changes since HIGH_SCN.</p>
<p>Let&#8217;s see how many blocks were modified after SCN 69732272706.</p>
<p>It is really easy:</p>
<p><code>dbv userid=sys/?????????? file=/tmp/test.dbf HIGH_SCN=69732272706</code></p>
<p><code>Page 64635 SCN 1012797077 (16.1012797077) exceeds highest scn to check 1012795970 (16.1012795970)</code></p>
<p><code>Page 66065 SCN 1012796687 (16.1012796687) exceeds highest scn to check 1012795970 (16.1012795970)</code></p>
<p><code>Page 66187 SCN 1012796687 (16.1012796687) exceeds highest scn to check 1012795970 (16.1012795970)</code></p>
<p><code>Page 87759 SCN 1012796692 (16.1012796692) exceeds highest scn to check 1012795970 (16.1012795970)</code></p>
<p><code>DBVERIFY - Verification complete</code></p>
<p><code>Total Pages Examined : 93440</code></p>
<p><code>Total Pages Processed (Data) : 62512</code></p>
<p><code>Total Pages Failing (Data) : 0</code></p>
<p><code>Total Pages Processed (Index): 9399</code></p>
<p><code>Total Pages Failing (Index): 0</code></p>
<p><code>Total Pages Processed (Other): 6119</code></p>
<p><code>Total Pages Processed (Seg) : 1705</code></p>
<p><code>Total Pages Failing (Seg) : 0</code></p>
<p><code>Total Pages Empty : 13705</code></p>
<p><code>Total Pages Marked Corrupt : 0</code></p>
<p><code>Total Pages Influx : 0</code></p>
<p><code>Total Pages Encrypted : 0</code></p>
<p><code>Total Pages Exceeding Highest Block SCN Specified: 39</code></p>
<p><code>Highest block SCN : 1012797131 (16.1012797131)</code></p>
<p>In this case, only 39 blocks (out of 100K) were modified after SCN 69732272706.</p>
<p>Please note that even though DBVerify (dbv) can work with open DB files, it will not account for changed blocks that were not yet written to the file.</p>
<p>Also, as per MOS document 985284.1 &#8211; &#8221;  Why HIGH_SCN Option Doesn&#8217;t Work While Running DBV Against ASM Files?&#8221; &#8211; the HIGH_SCN flag works only for files that are not stored in ASM. Hope they fix that problem soon. </p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/409/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/409/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=409&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2013/05/14/measuring-the-benefits-of-database-virtualizationthin-provisioning-solutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
		<item>
		<title>Hotsos Symposium 2013 continued</title>
		<link>http://iiotzov.wordpress.com/2013/04/19/hotsos-symposium-2013-continued/</link>
		<comments>http://iiotzov.wordpress.com/2013/04/19/hotsos-symposium-2013-continued/#comments</comments>
		<pubDate>Fri, 19 Apr 2013 20:43:12 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Cardinality Estimate Errors]]></category>
		<category><![CDATA[confidence levels]]></category>
		<category><![CDATA[Confidence of Cardinality Estimate]]></category>
		<category><![CDATA[execution plan]]></category>
		<category><![CDATA[Oracle Cardinality Estimate]]></category>
		<category><![CDATA[Oracle CBO Cardinality Estimate]]></category>
		<category><![CDATA[Oracle CBO errors]]></category>
		<category><![CDATA[oracle incorrect cardinality]]></category>
		<category><![CDATA[oracle optimizer bad cardinality]]></category>
		<category><![CDATA[oracle optimizer incorrect cardinality]]></category>
		<category><![CDATA[Reason for Incorrect Cardinality Estimate]]></category>
		<category><![CDATA[reason incorrect cardinality]]></category>
		<category><![CDATA[reason incorrect cardinality oracle]]></category>
		<category><![CDATA[Reasons Oracle CBO errors]]></category>
		<category><![CDATA[Relative error cardinality]]></category>
		<category><![CDATA[Tuning by Cardinality Feedback]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=414</guid>
		<description><![CDATA[During my presentation at Hotsos 2013, an attendee questioned my statement that each filter/selection predicate contributes to the overall cardinality error. She believed that only the predicate with the maximum error mattered. I believe the following paper supports my position: http://www.btw-2013.de/proceedings/Taking%20the%20Edge%20off%20Cardinality%20Estimation%20Errors%20using%20Incremental%20Execution.pdf I got the Hotsos 2013 &#8220;Speaker scoring and verbatim comments&#8221; information a couple of weeks [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=414&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>During my presentation at Hotsos 2013, an attendee questioned my statement that each filter/selection predicate contributes to the overall cardinality error. She believed that only the predicate with the maximum error mattered.</p>
<p>I believe the following paper supports my position:</p>
<p><a href="http://www.btw-2013.de/proceedings/Taking%20the%20Edge%20off%20Cardinality%20Estimation%20Errors%20using%20Incremental%20Execution.pdf">http://www.btw-2013.de/proceedings/Taking%20the%20Edge%20off%20Cardinality%20Estimation%20Errors%20using%20Incremental%20Execution.pdf</a></p>
<p>I got the Hotsos 2013 &#8220;Speaker scoring and verbatim comments&#8221; information a couple of weeks ago.</p>
<p>I am happy that the presentation was very well received!!!</p>
<p>Thanks for your feedback. I appreciate all your comments. They would not only making  this presentation better, but also improve my skills as a speaker.</p>
<p>Here are some of the comments:</p>
<p><b><i>This was an intriguing   session, but I left feeling like there was still much more to be said on the   subject.</i></b></p>
<p>There is indeed much more to be said. The problem with digging deeper in the subject is that it gets quite academic and might be less interesting for the audience. The article I mentioned earlier in the post, as well as Ioannidis Y. And S. Christodoulakis (1991) paper cited in the reference can be a good starting point for further research.</p>
<p><b><i>is this accurate, did Maria review this info?</i></b></p>
<p>Good question <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I am not sure who reviewed the paper before the presentation, but I believe that Maria Colgan was in audience. I too will be very interested in her feedback…</p>
<p><b><i>He spent a lot of time talking about Terradata, The package he showed seemed way to simplistic to be of any real practical use. He did show some creative ideas on solving some issues, however there wasn&#8217;t a real example to show how to do what he purposed.</i></b></p>
<p>The package is quite limited for most practical uses. It was intended to be for “demonstration purposes only”.</p>
<p>Fair point about examples though. I’ll try to publish some examples in this blog in the coming months. Stay tuned…</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/414/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/414/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=414&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2013/04/19/hotsos-symposium-2013-continued/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
		<item>
		<title>Hotsos Symposium 2013</title>
		<link>http://iiotzov.wordpress.com/2013/03/14/hotsos-symposium-2013/</link>
		<comments>http://iiotzov.wordpress.com/2013/03/14/hotsos-symposium-2013/#comments</comments>
		<pubDate>Thu, 14 Mar 2013 19:04:18 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Cardinality Estimate Errors]]></category>
		<category><![CDATA[confidence levels]]></category>
		<category><![CDATA[Confidence of Cardinality Estimate]]></category>
		<category><![CDATA[execution plan]]></category>
		<category><![CDATA[Oracle Cardinality Estimate]]></category>
		<category><![CDATA[Oracle CBO Cardinality Estimate]]></category>
		<category><![CDATA[Oracle CBO errors]]></category>
		<category><![CDATA[oracle incorrect cardinality]]></category>
		<category><![CDATA[oracle optimizer bad cardinality]]></category>
		<category><![CDATA[oracle optimizer incorrect cardinality]]></category>
		<category><![CDATA[Reason for Incorrect Cardinality Estimate]]></category>
		<category><![CDATA[reason incorrect cardinality]]></category>
		<category><![CDATA[reason incorrect cardinality oracle]]></category>
		<category><![CDATA[Reasons Oracle CBO errors]]></category>
		<category><![CDATA[Relative error cardinality]]></category>
		<category><![CDATA[Tuning by Cardinality Feedback]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=392</guid>
		<description><![CDATA[It was a great pleasure presenting at Hotsos. Thank you for attending my presentation &#8211; your comments and questions were quite insightful. I owe a bit more explanation to the lady who asked about the mechanism/formula for passing filter errors into the resulting set. I’ll get more information about that soon – stay tuned. Title: [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=392&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>It was a great pleasure presenting at Hotsos.</p>
<p>Thank you for attending my presentation &#8211; your comments and questions were quite insightful. I owe a bit more explanation to the lady who asked about the mechanism/formula for passing filter errors into the resulting set. I’ll get more information about that soon – stay tuned.</p>
<p><strong>Title:</strong></p>
<p>Working with Confidence: How Sure Is the Oracle CBO about its Cardinality Estimates, and Why Does It Matter?</p>
<p><strong>Abstract:</strong></p>
<p>The Oracle CBO is tasked to provide an execution plan for every syntactically correct statement. To tackle this very broad requirement, the CBO has to come up with selectivity coefficients for every possible type of predicate. In some cases, the selectivity coefficients are deeply rooted in math and common sense — we know for a fact that lookup by primary key would result in one or zero records.</p>
<p>In other cases, however, the CBO has to take a guess, sometimes even a wild guess, on how much a particular predicate would affect the cardinality of the resulting set. A simple LIKE clause with a leading wildcard would force the CBO to default the selectivity coefficient to around 5%, a guess that could be very far from reality.</p>
<p>To measure the level of guesswork employed by the CBO, the notion of &#8220;confidence&#8221; level of a cardinality estimate is introduced. Estimates of the confidence level the Oracle CBO should be getting for common SQL predicates are presented. The effects of joins on the confidence levels are reviewed as well as methods to reduce the level of guesswork the optimizer has to employ.</p>
<p>The practical implications of considering CBO&#8217;s confidence in its cardinality estimates are discussed in detail. Guidelines on how to vet new SQL and PL/SQL features, designs, and coding standards are given to aid the CBO in avoiding unnecessary guesses about predicate selectivity. A technique for analysis and resolution of performance issues based on dealing with constructs that force the CBO to make guesses is presented.</p>
<p><strong>Files:</strong></p>
<p>The presentation is <a href="http://iiotzov.wordpress.com/?attachment_id=395">here</a>.</p>
<p>The white paper is <a href="http://iiotzov.wordpress.com/?attachment_id=396">here</a>. It is quite comprehensive, with lots of details and references.</p>
<p>Use XPLAN_CONFIDENCE package entirely at your own risk:</p>
<p>The deployment instructions are <a href="http://iiotzov.wordpress.com/?attachment_id=397">here</a>. The spec of the package is <a href="http://iiotzov.wordpress.com/?attachment_id=398">here</a>, and the body is <a href="http://iiotzov.wordpress.com/?attachment_id=399">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/392/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=392&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2013/03/14/hotsos-symposium-2013/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
		<item>
		<title>Dependent/correlated sets in Oracle – definition, problems and solutions.</title>
		<link>http://iiotzov.wordpress.com/2013/02/27/dependentcorrelated-sets-in-oracle-definition-problems-and-solutions/</link>
		<comments>http://iiotzov.wordpress.com/2013/02/27/dependentcorrelated-sets-in-oracle-definition-problems-and-solutions/#comments</comments>
		<pubDate>Wed, 27 Feb 2013 16:48:32 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[cardinality correlated sets Oracle]]></category>
		<category><![CDATA[cardinality dependent sets Oracle]]></category>
		<category><![CDATA[correlated sets Oracle]]></category>
		<category><![CDATA[dependent sets Oracle]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=366</guid>
		<description><![CDATA[To better understand dependent/correlated sets, let’s take a brief look at dependent/correlated columns. Oracle works under the assumption that the data in each column is independent. If an equality predicate on column COL1 leaves 10% of the records, and an equality predicate on column COL2 leaves 20% of the records, then by default, the Oracle [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=366&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>To better understand dependent/correlated sets, let’s take a brief look at dependent/correlated columns.</p>
<p>Oracle works under the assumption that the data in each column is independent. If an equality predicate on column COL1 leaves 10% of the records, and an equality predicate on column COL2 leaves 20% of the records, then by default, the Oracle CBO would assume that predicates on both COL1 and COL2 would leave 2 % (10%x20%) of the records. If the data is COL1 is correlated with the data in COL2 then equality predicates on both COL1 and COL2 would leave significantly more than 2% of the records. That difference in estimated cardinality could cause huge troubles when estimating consequent execution steps.</p>
<p>Oracle recognized the problem and came with a comprehensive solution – extended statistics in Oracle 11g.</p>
<p>Now about dependent/correlated sets &#8211; two sets are dependent/correlated if they contain the same or similar records. Oracle assumes that sets are independent. If a predicate like this <em>“COL1 IN (select.. from .. SET1 ) “</em>  leaves 10% of the records, and a similar predicate <em>“COL1 IN (select.. from .. SET2 ) “</em>  leaves 20% of the records, then Oracle assumed that both predicates <em>“COL1 IN (select.. from .. SET1 ) “ AND “COL1 IN (select.. from .. SET2 ) “</em>   would leave 2%(10%x20%) of the records. If SET1 is identical or very similar to SET2, then the <em>“COL1 IN (select.. from .. SET1 ) “ AND “COL1 IN (select.. from .. SET2 ) “</em> would leave significantly more than 2% of the records. Needless to say, the difference in estimated cardinality could cause huge troubles when estimating consequent execution steps.</p>
<p>The big challenge is that there is nothing out of the box that can help us in the above scenario.</p>
<p>Tables TAB1 and TAB2 would provide us with the correlated sets (SET1,SET2)</p>
<p><code>create table tab1 as</code><br />
<code>with generator as (</code><br />
<code>select</code><br />
<code>  rownum id</code><br />
<code> from dual</code><br />
<code> connect by</code><br />
<code>  rownum &lt;= 4000</code><br />
<code>)</code><br />
<code>select</code><br />
<code>  id col1, </code><br />
<code>  mod(id,1024) col2 , </code><br />
<code>  mod(id,2) col3</code><br />
<code>from (</code><br />
<code>   select</code><br />
<code>     /*+ no_merge */</code><br />
<code>     rownum id</code><br />
<code>   from</code><br />
<code>     generator,</code><br />
<code>     generator</code><br />
<code>   where</code><br />
<code>     rownum &lt;= 1000000</code><br />
<code>)</code><br />
<code>;</code></p>
<p><code>create table tab2 as</code><br />
<code>with generator as (</code><br />
<code>select</code><br />
<code>  rownum id</code><br />
<code> from dual</code><br />
<code> connect by</code><br />
<code>  rownum &lt;= 4000</code><br />
<code>)</code><br />
<code>select</code><br />
<code>  id col1, </code><br />
<code>  mod(id,1024) + 134 col2 , </code><br />
<code>  mod(id,2) col3</code><br />
<code>from (</code><br />
<code>   select</code><br />
<code>     /*+ no_merge */</code><br />
<code>     rownum id</code><br />
<code>   from</code><br />
<code>     generator,</code><br />
<code>     generator</code><br />
<code>   where</code><br />
<code> rownum &lt;= 1000000</code><br />
<code>)</code><br />
<code>;</code></p>
<p>TAB3 would be the table we are going to apply the filters with those correlated sets</p>
<p><code>create table tab3 as</code><br />
<code>with generator as (</code><br />
<code>select</code><br />
<code>  rownum id</code><br />
<code> from dual</code><br />
<code> connect by</code><br />
<code>  rownum &lt;= 4000</code><br />
<code>)</code><br />
<code>select</code><br />
<code>  id col1</code><br />
<code>from (</code><br />
<code>   select</code><br />
<code>     /*+ no_merge */</code><br />
<code>     rownum id</code><br />
<code>   from</code><br />
<code>     generator,</code><br />
<code>     generator</code><br />
<code>   where</code><br />
<code> rownum &lt;= 1000000000</code><br />
<code>)</code></p>
<p>Gather stats:</p>
<p><code>exec dbms_stats.gather_table_stats(NULL,'TAB1');</code></p>
<p><code>exec dbms_stats.gather_table_stats(NULL,'TAB2');</code></p>
<p><code>exec dbms_stats.gather_table_stats(NULL,'TAB3');</code></p>
<p>The query we are interested in is</p>
<p><code>select </code><br />
<code>    t3.col1</code><br />
<code>from</code><br />
<code>    tab3 t3 ,</code><br />
<code>    tab1 t1 ,</code><br />
<code>    tab2 t2</code><br />
<code>where </code><br />
<strong><code>   </code></strong><code> t3.col1 = t1.col1</code><br />
<code>and t1.col2 in (66,166,316,416,516,616)</code><br />
<code>and</code><code> t3.col1 = t2.col1</code><br />
<code>and t2.col2 in (200,300,450,550,650,750)</code><br />
<code>and t1.col3 = t2.col3</code></p>
<p>Please note that the sets that come from TAB1 and TAB2 are identical, so this clause</p>
<p><code>t3.col1 = t1.col1 and t3.col1 = t2.col1</code></p>
<p>would eliminate significantly fewer records that Oracle CBO’s estimate.</p>
<p>Due to the described dependent/correlated sets behaviors, the CBO (DBMS_XPLAN.DISPLAY_CURSOR) estimates that only 17 records will be returned by the query, even though the query returns 5861 records.</p>
<p><code>---------------------------------------------------------</code><br />
<code>| Id | Operation         |Name |Rows |Bytes |Cost (%CPU)|</code><br />
<code>---------------------------------------------------------</code><br />
<code>| 0  | SELECT STATEMENT  |     |     |      |8182 (100) |</code><br />
<code>|* 1 | HASH JOIN         |     |17   |510   |8182 (4)   |</code><br />
<code>|* 2 | TABLE ACCESS FULL |TAB2 |5859 |70308 |657 (4)    |</code><br />
<code>|* 3 | HASH JOIN         |     |5872 |103K  |7524 (4)   |</code><br />
<code>|* 4 | TABLE ACCESS FULL |TAB1 |5859 |70308 |653 (4)    |</code><br />
<code>| 5  | TABLE ACCESS FULL |TAB3 |16M  |91M   |6786 (2)   |</code><br />
<code>---------------------------------------------------------</code></p>
<p><code>Predicate Information (identified by operation id):</code><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><code>1 - access("T3"."COL1"="T2"."COL1" AND "T1"."COL3"="T2"."COL3")</code><br />
<code>2 - filter(("T2"."COL2"=200 OR "T2"."COL2"=300 OR "T2"."COL2"=450 OR</code><br />
<code>"T2"."COL2"=550 OR "T2"."COL2"=650 OR "T2"."COL2"=750))</code><br />
<code>3 - access("T3"."COL1"="T1"."COL1")</code><br />
<code>4 - filter(("T1"."COL2"=66 OR "T1"."COL2"=166 OR "T1"."COL2"=316 OR</code><br />
<code>"T1"."COL2"=416 OR "T1"."COL2"=516 OR "T1"."COL2"=616))</code></p>
<p>Dynamic sampling, even at the max level, actually makes the estimate worse</p>
<p><code>exec dbms_stats.delete_table_stats(NULL,'TAB1');</code></p>
<p><code>exec dbms_stats.delete_table_stats(NULL,'TAB2');</code></p>
<p><code>exec dbms_stats.delete_table_stats(NULL,'TAB3');</code></p>
<p><code>alter session set optimizer_dynamic_sampling=10</code></p>
<p><code>---------------------------------------------------------</code><br />
<code>| Id | Operation         |Name |Rows |Bytes |Cost (%CPU)|</code><br />
<code>---------------------------------------------------------</code><br />
<code>| 0  | SELECT STATEMENT  |     |     |      |8156 (100) |</code><br />
<code>|* 1 | HASH JOIN         |     |1    |91    |8156 (4)   |</code><br />
<code>|* 2 | TABLE ACCESS FULL |TAB2 |5861 |223K  |644 (3)    |</code><br />
<code>|* 3 | HASH JOIN         |     |5861 |297K  |7511 (4)   |</code><br />
<code>|* 4 | TABLE ACCESS FULL |TAB1 |5861 |223K  |640 (3)    |</code><br />
<code>| 5  | TABLE ACCESS FULL |TAB3 |16M  |198M  |6786 (2)   |</code><br />
<code>---------------------------------------------------------</code></p>
<p><code>Predicate Information (identified by operation id):</code><br />
<code>---------------------------------------------------</code></p>
<p><code>1 - access("T3"."COL1"="T2"."COL1" AND "T1"."COL3"="T2"."COL3")</code><br />
<code>2 - filter(("T2"."COL2"=200 OR "T2"."COL2"=300 OR "T2"."COL2"=450 OR</code><br />
<code>"T2"."COL2"=550 OR "T2"."COL2"=650 OR "T2"."COL2"=750))</code><br />
<code>3 - access("T3"."COL1"="T1"."COL1")</code><br />
<code>4 - filter(("T1"."COL2"=66 OR "T1"."COL2"=166 OR "T1"."COL2"=316 OR</code><br />
<code>"T1"."COL2"=416 OR "T1"."COL2"=516 OR "T1"."COL2"=616))</code></p>
<p><code>Note</code><br />
<code>-----</code><br />
<code>- dynamic sampling used for this statement (level=10)</code></p>
<p>One way to resolve this is to force the execution order, so TAB3 is visited before TAB2 or TAB1.</p>
<p>Another solution is to create a virtual column identical to COL1</p>
<p><code>alter table tab3 add col1_corr generated always as (col1*1 ) not null ;</code></p>
<p>,gather stats</p>
<p><code>exec dbms_stats.gather_table_stats(NULL,'TAB1');</code></p>
<p><code>exec dbms_stats.gather_table_stats(NULL,'TAB2');</code></p>
<p><code>exec dbms_stats.gather_table_stats(NULL,'TAB3');</code></p>
<p>Then set the number of distinct records for that new virtual column to 1</p>
<p><code>exec dbms_stats.set_column_stats(NULL,'TAB3','COL1_CORR',distcnt=&gt;1);</code></p>
<p>and use the new virtual column (COL1_CORR), instead of COL1,  for one of the predicates</p>
<p><code>select</code><br />
<code>t3.col1</code><br />
<code>from </code><br />
<code>    tab3 t3 ,</code><br />
<code>    tab1 t1 ,</code><br />
<code>    tab2 t2</code><br />
<code>where</code><br />
<code>    t3.col1_corr = t1.col1</code><br />
<code>and t1.col2 in (66,166,316,416,516,616)</code><br />
<code>and t3.col1 = t2.col1</code><br />
<code>and t2.col2 in (200,300,450,550,650,750)</code><br />
<code>and t1.col3 = t2.col3</code></p>
<p>Now, the CBO expects 2936 records – much better than the original 17 records.</p>
<p><code>---------------------------------------------------------</code><br />
<code>| Id | Operation         |Name |Rows |Bytes |Cost (%CPU)|</code><br />
<code>---------------------------------------------------------</code><br />
<code>| 0  | SELECT STATEMENT  |     |     |      |8182 (100) |</code><br />
<code>|* 1 | HASH JOIN         |     |2936 |103K  |8182 (4)   |</code><br />
<code>|* 2 | TABLE ACCESS FULL |TAB1 |5859 |70308 |653 (4)    |</code><br />
<code>|* 3 | HASH JOIN         |     |5872 |137K  |7528 (4)   |</code><br />
<code>|* 4 | TABLE ACCESS FULL |TAB2 |5859 |70308 |657 (4)    |</code><br />
<code>| 5  | TABLE ACCESS FULL |TAB3 |16M  |183M  |6786 (2)   |</code><br />
<code>---------------------------------------------------------</code></p>
<p><code>Predicate Information (identified by operation id):</code><br />
<code>---------------------------------------------------</code></p>
<p><code> 1 - access("COL1"*1="T1"."COL1" AND "T1"."COL3"="T2"."COL3")</code><br />
<code> 2 - filter(("T1"."COL2"=66 OR "T1"."COL2"=166 OR "T1"."COL2"=316 OR</code><br />
<code>"T1"."COL2"=416 OR "T1"."COL2"=516 OR "T1"."COL2"=616))</code><br />
<code> 3 - access("T3"."COL1"="T2"."COL1")</code><br />
<code> 4 - filter(("T2"."COL2"=200 OR "T2"."COL2"=300 OR "T2"."COL2"=450 OR</code><br />
<code>"T2"."COL2"=550 OR "T2"."COL2"=650 OR "T2"."COL2"=750))</code></p>
<p>Setting the number of distinct values for COL1_CORR to 1 forced the CBO to believe that the clause on COL1_CORR would not eliminate any records. That’s the only way (for me anyway) to tell the optimizer that the COL1_CORR clause would not further reduce the number of records.</p>
<p>Interestingly, I get the same result for any value of distcnt …</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/366/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/366/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=366&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2013/02/27/dependentcorrelated-sets-in-oracle-definition-problems-and-solutions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
		<item>
		<title>Hotsos 2013 and some more useful OEM queries</title>
		<link>http://iiotzov.wordpress.com/2013/01/31/hotsos-2013-and-some-more-useful-oem-queries/</link>
		<comments>http://iiotzov.wordpress.com/2013/01/31/hotsos-2013-and-some-more-useful-oem-queries/#comments</comments>
		<pubDate>Fri, 01 Feb 2013 00:10:03 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Enterprise Manager]]></category>
		<category><![CDATA[Resource Management]]></category>
		<category><![CDATA[CPU utilization OEM repository]]></category>
		<category><![CDATA[CPU utilization OMS repository]]></category>
		<category><![CDATA[MGMT_ECM_HW]]></category>
		<category><![CDATA[OEM MGMT_ECM_HW]]></category>
		<category><![CDATA[Oracle Enterprise Manager Cloud Control 12c]]></category>
		<category><![CDATA[Oracle Enterprise Manager Repository]]></category>
		<category><![CDATA[query against OEM repository]]></category>
		<category><![CDATA[sever consolidation OEM repository]]></category>
		<category><![CDATA[sever virtualization OEM repository]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=355</guid>
		<description><![CDATA[Busy preparing for Hotsos 2013. My presentation this year is “Working with Confidence: How Sure Is the Oracle CBO about Its Cardinality Estimates, and Why Does It Matter?” I know it is a mouthful. The presentation/white paper would be up to the point with lots of pictures though The only thing I have for the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=355&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Busy preparing for Hotsos 2013. My presentation this year is “Working with Confidence: How Sure Is the Oracle CBO about Its Cardinality Estimates, and Why Does It Matter?” I know it is a mouthful. The presentation/white paper would be up to the point with lots of pictures though <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The only thing I have for the blog now is a revised version of a query I posted the last time. The original version was way too crude.</p>
<p><code>select   a.rollup_timestamp ,</code></p>
<p><code>         count(*) ,</code></p>
<p><code>         sum(c.cpu_count) ,</code></p>
<p><code>         sum(a.average*c.cpu_count)/ sum(c.cpu_count) ,</code></p>
<p><code>         sum(a.maximum*c.cpu_count)/ sum(c.cpu_count) ,</code></p>
<p><code>         sum((a.average+3*a.standard_deviation)*c.cpu_count) / sum(c.cpu_count)</code></p>
<p><code>from</code></p>
<p><code>         mgmt$metric_hourly a ,</code></p>
<p><code>         mgmt$target b ,</code></p>
<p><code>         sysman.MGMT_ECM_HW c</code></p>
<p><code>where    </code><code>a.metric_name = 'Load'</code></p>
<p><code>and      a.column_label = 'CPU Utilization (%)'</code></p>
<p><code>and      a.target_guid = b.target_guid</code></p>
<p><code>and      b.target_name like 'dev%'</code></p>
<p><code>and      c.hostname||'.'||c.domain = b.target_name</code></p>
<p><code>and      c.vendor_name = 'Intel Based Hardware'</code></p>
<p><code>group by a.rollup_timestamp</code></p>
<p><code>order by 5 desc</code></p>
<p>The query now takes into account the number of CPUs on a server. I use the undocumented MGMT_ECM_HW view – it contains a wealth of information.</p>
<p>The query assumes that all CPUs are identical – not perfect, but much better than the original.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/355/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=355&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2013/01/31/hotsos-2013-and-some-more-useful-oem-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
		<item>
		<title>More Useful OEM Repository Queries</title>
		<link>http://iiotzov.wordpress.com/2012/12/31/some-more-useful-oem-repository-queries/</link>
		<comments>http://iiotzov.wordpress.com/2012/12/31/some-more-useful-oem-repository-queries/#comments</comments>
		<pubDate>Mon, 31 Dec 2012 18:49:57 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Enterprise Manager]]></category>
		<category><![CDATA[Resource Management]]></category>
		<category><![CDATA[CPU utilization OEM repository]]></category>
		<category><![CDATA[CPU utilization OMS repository]]></category>
		<category><![CDATA[Oracle Enterprise Manager Cloud Control 12c]]></category>
		<category><![CDATA[Oracle Enterprise Manager Repository]]></category>
		<category><![CDATA[query against OEM repository]]></category>
		<category><![CDATA[sever consolidation OEM repository]]></category>
		<category><![CDATA[sever virtualization OEM repository]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=338</guid>
		<description><![CDATA[I already included a number of queries against the OEM repository in my presentation. Now, I would like to add two more. The first query shows an approximation of the average and max CPU utilization for a group of servers (names starting with &#8220;dev&#8221;). Since the query assumed that each server has the same &#8220;weight&#8221;, [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=338&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I already included a number of queries against the OEM repository in <a href="http://iiotzov.wordpress.com/?attachment_id=262">my presentation</a>.<br />
Now, I would like to add two more.</p>
<p>The first query shows an approximation of the average and max CPU utilization for a group of servers (names starting with &#8220;dev&#8221;).<br />
Since the query assumed that each server has the same &#8220;weight&#8221;, the results are not completely correct for most environments.<br />
They are a good start for a consolidation and/or virtualization projects though.</p>
<p><code>select</code><br />
<code>      a.rollup_timestamp           time, </code><br />
<code>      count(*)                     number_of_servers,</code><br />
<code>      sum(a.average)/count(*)      average_load , </code><br />
<code>      sum(a.maximum)/count(*)      max_recorded, </code><br />
<code>      sum(a.average+3*a.standard_deviation)/count(*) max_derived</code><br />
<code>from</code><br />
<code>      mgmt$metric_hourly a ,</code><br />
<code>      mgmt$target b</code><br />
<code>where </code><br />
<code>      a.metric_name = 'Load'</code><br />
<code>  and a.column_label = 'CPU Utilization (%)'</code><br />
<code>  and a.target_guid = b.target_guid</code><br />
<code>  and b.target_name like 'dev%'</code><br />
<code>group by a.rollup_timestamp</code><br />
<code>order by max_derived desc</code></p>
<p>1/31/2013 &#8211; The query above is quite crude - I just posted a better query  &#8211; <a href="http://wp.me/p1DHW2-5J">http://wp.me/p1DHW2-5J</a></p>
<p>The second query shows all databases that belong to the TEST OEM group and are in ARCHIVELOG mode. The query can be modified to look at all databases or to any subset.</p>
<p><code>select</code><code> *</code><br />
<code> from </code><br />
<code>sysman.MGMT$GROUP_DERIVED_MEMBERSHIPS O ,</code><br />
<code>    sysman.MGMT$TARGET T ,</code><br />
<code>    sysman.MGMT$AVAILABILITY_CURRENT st</code><br />
w<code>here     </code><br />
<code>     o.composite_target_name = 'TEST'</code><br />
<code>and  o.member_target_type IN ('oracle_database', 'rac_database')</code><br />
<code>and  ( t.target_type ='rac_database'</code><br />
<code>       or (t.target_type ='oracle_database'</code><br />
<code>           and t.type_qualifier3 != 'RACINST'))</code><br />
and<code>  o. member_target_guid = t.target_guid</code><br />
<code>and  t.target_guid = st.target_guid</code><br />
<code>and  st.availability_status = 'Target Up'</code><br />
<code>and  (not exists </code><br />
<code>      (select</code><br />
<code>             *</code><br />
<code>       from</code><br />
<code>            sysman.mgmt$metric_current i</code><br />
<code>       where </code><br />
<code>             i.target_guid = o.member_target_guid </code><br />
<code>       and   metric_name   = 'archFull'</code><br />
<code>       and   metric_Column = 'archTotal'</code><br />
<code>       and   metric_label  = 'Archive Area'</code><br />
<code>       and   column_label  = 'Total Archive Area (KB)'</code><br />
<code>       and   key_value     = 'NOARCHIVELOG'</code><br />
<code>    ));</code></p>
<p>This query is not strictly based on the documentation, but it work in OEM 12c.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/338/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=338&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2012/12/31/some-more-useful-oem-repository-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
		<item>
		<title>Same SQL_ID, same execution plan (SQL_PLAN_HASH_VALUE), greatly different elapsed time &#8211; a simple way to troubleshoot this problem with ASH</title>
		<link>http://iiotzov.wordpress.com/2012/11/27/same-sql_id-same-execution-plan-sql_plan_hash_value-greatly-different-elapsed-time-a-simple-way-to-troubleshoot-with-ash/</link>
		<comments>http://iiotzov.wordpress.com/2012/11/27/same-sql_id-same-execution-plan-sql_plan_hash_value-greatly-different-elapsed-time-a-simple-way-to-troubleshoot-with-ash/#comments</comments>
		<pubDate>Tue, 27 Nov 2012 20:37:04 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Oracle Active Sessin History]]></category>
		<category><![CDATA[Oracle troubleshooting SQL]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=328</guid>
		<description><![CDATA[A query runs fine in one environment, but is terrible in another. The usual suspects – different execution plan, hardware issues, etc are ruled out. The next step is to look at the actual execution statistics and see where the difference is. Re-executing the statements with GATHER_PLAN_STATISTICS hint was not an option. SQL Monitoring was running, [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=328&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A query runs fine in one environment, but is terrible in another. The usual suspects – different execution plan, hardware issues, etc are ruled out.</p>
<p>The next step is to look at the actual execution statistics and see where the difference is. Re-executing the statements with GATHER_PLAN_STATISTICS hint was not an option. SQL Monitoring was running, but the query was behind the retention period.</p>
<p>This is where the Oracle Active Session history (ASH), a separately licenses option, comes to play.</p>
<p>Using sql_plan_line_id column in dba_hist_active_sess_history ASH view to get load profile is not new &#8211; <a href="http://eastcoastoracle.org/PDF_files/2011/Presentations/BarunSQL_Performance_Tuning_with_Oracle_ASH_AWR_Real_World_Use_Cases_Public.pdf">http://eastcoastoracle.org/PDF_files/2011/Presentations/BarunSQL_Performance_Tuning_with_Oracle_ASH_AWR_Real_World_Use_Cases_Public.pdf</a> .</p>
<p>Similar technique can be used to easily find out from which plan step onwards the two execution plans start to differ.</p>
<p>At DB1:<br />
<code>select sql_plan_line_id , count(*) </code><br />
<code>from dba_hist_active_sess_history</code><br />
<code>where </code><br />
<code>    sql_id = 'fmhbn1tn0c54z'</code><br />
<code>and sample_time</code><br />
<code>         between to_date('11/26/2012:10:00:00','MM/DD/YYYY:HH24:MI</code>:SS&#8217;)<br />
<code>         and to_date('11/26/2012:11:00:00','MM/DD/YYYY:HH24:MI</code>:SS&#8217;)<br />
<code>group by sql_plan_line_id</code><br />
<code>order by 1</code></p>
<p><code>"SQL_PLAN_LINE_ID" "COUNT(*)"</code><br />
<code>34                 135</code><br />
<code>35                 5</code><br />
<code>36                 2</code><br />
<code>37                 1</code><br />
<code>"" 2"",            2</code></p>
<p>At DB2:<br />
<code>select sql_plan_line_id , count(*) </code><br />
<code>from dba_hist_active_sess_history</code><br />
<code>where </code><br />
<code>    sql_id = 'fmhbn1tn0c54z'</code><br />
<code>and sample_time</code><br />
<code>        between to_date('11/25/2012:09:00:00','MM/DD/YYYY:HH24:MI</code>:SS&#8217;)<br />
<code>        and to_date('11/25/2012:10:00:00','MM/DD/YYYY:HH24:MI</code>:SS&#8217;)<br />
<code>group by sql_plan_line_id</code><br />
<code>order by 1</code></p>
<p><code>"SQL_PLAN_LINE_ID" "COUNT(*)"</code><br />
<code>33                  467</code> <strong>&lt;&#8212;&#8212; Deviation </strong><br />
<code>34                  135</code><br />
<code>35                  5</code><br />
<code>36                  2</code><br />
<code>37                  1</code><br />
<code>"" 2"",             2</code></p>
<p>We see that the difference starts at line 33 of the execution plan, and we can focus on finding the root cause.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/328/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=328&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2012/11/27/same-sql_id-same-execution-plan-sql_plan_hash_value-greatly-different-elapsed-time-a-simple-way-to-troubleshoot-with-ash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
		<item>
		<title>“ORA-20008 Number of extensions …”  &#8211; what to do about this unnecessary error</title>
		<link>http://iiotzov.wordpress.com/2012/10/28/ora-20008-number-of-extensions-what-to-do-about-this-unnecessary-error/</link>
		<comments>http://iiotzov.wordpress.com/2012/10/28/ora-20008-number-of-extensions-what-to-do-about-this-unnecessary-error/#comments</comments>
		<pubDate>Sun, 28 Oct 2012 20:03:31 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Oracle extended statistics]]></category>
		<category><![CDATA[Oracle extended stats]]></category>
		<category><![CDATA[Oracle ORA-20008]]></category>
		<category><![CDATA[pick groups for extended statistics]]></category>
		<category><![CDATA[select extended stats groups.]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=320</guid>
		<description><![CDATA[There are times when Oracle puts restrictions to save us from our own bad practices. For instance, committing in triggers is forbidden so we do not make a mess, among other things. And then there is “ORA-20008: Number of extensions in table &#8230;.. already reaches the upper limit (20)”. We can create thousands of tables, each [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=320&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>There are times when Oracle puts restrictions to save us from our own bad practices. For instance, committing in triggers is forbidden so we do not make a mess, among other things.</p>
<p>And then there is “ORA-20008: Number of extensions in table &#8230;.. already reaches the upper limit (20)”. We can create thousands of tables, each of them with thousands of columns, but when we create column groups/extended stats, we face severe limitations &#8211; 20 or 10% of the number of columns. Why?!? It takes little disk space to accommodate those statistics. The incremental impact on the time to gather stats would be quite small as well.</p>
<p>In short, this restriction has no technologies or business sense, it is probably trivial to correct, but it is still there (as of 11.2.0.3.0).</p>
<p>Some would think that this restriction would almost never affect a &#8220;real&#8221; system. I disagree! A fact table in a data-warehouse environment could be queried in many different ways – and that’s the beauty of the Kimball approach. I have personally seen this situation in my systems a couple of times so far.</p>
<p>Then what can we do about it?</p>
<p>If the extended statics were generated automatically using the methods here</p>
<p><a href="http://iiotzov.wordpress.com/2011/11/01/get-the-max-of-oracle-11gr2-right-from-the-start-create-relevant-extended-statistics-as-a-part-of-the-upgrade">http://iiotzov.wordpress.com/2011/11/01/get-the-max-of-oracle-11gr2-right-from-the-start-create-relevant-extended-statistics-as-a-part-of-the-upgrade</a></p>
<p><a href="http://blogs.oracle.com/optimizer/entry/how_do_i_know_what_extended_statistics_are_needed_for_a_given_workload">http://blogs.oracle.com/optimizer/entry/how_do_i_know_what_extended_statistics_are_needed_for_a_given_workload</a></p>
<p>, then we can weed out the extended statistics that do not help the CBO a lot, and put in place only those extended stats that make a significant difference.</p>
<p>Since CBO can use column groups with more columns than are present in predicates (<a href="http://www.hotsos.com/sym12/sym_speakers_matuszyk.html">http://www.hotsos.com/sym12/sym_speakers_matuszyk.html</a>) ,we can eliminate extended stats groups that are covered by another extended stats group.</p>
<p>Another way is to measure the dependent columns error (<em>err)/</em>correlation strength<em> (</em><a href="http://iiotzov.wordpress.com/2011/07/05/getting-the-best-of-oracle-extended-statistics">http://iiotzov.wordpress.com/2011/07/05/getting-the-best-of-oracle-extended-statistics</a><em>) </em>and eliminate those column groups with smallest dependent columns error.</p>
<p>Here is an example:</p>
<p><code>create table test_tab as</code><br />
<code>with v1 as (select rownum n from dual connect by level &lt;= 10000) </code><br />
<code>select</code><br />
<code>rownum  id , mod (rownum , 100) corr_gr1_col1, mod (rownum , 25) corr_gr1_col2 , mod (rownum ,</code><br />
<code>50) corr_gr1_col3 ,</code><br />
<code>200 +  mod (rownum , 11)  corr_gr2_col4 , 200 +  mod (rownum , 22)  corr_gr2_col5 , 200 + mod (</code><br />
<code>rownum , 33) corr_gr2_col6</code><br />
<code>from</code><br />
<code>v1, v1</code><br />
<code>where</code><br />
<code>rownum &lt;= 1000000</code><br />
<code> ;</code></p>
<p><code>Table created.</code></p>
<p><code> select dbms_stats.create_extended_stats (NULL,'TEST_TAB','(corr_gr1_col1,corr_gr1_col2)') from dual </code></p>
<p><code>--------------------------------------------------------------------------------</code></p>
<p><code>SYS_STU_4QATWX9PNVNKREP$YZIDOX</code></p>
<p>&#8230; 19 more CREATE_EXTENDED_STATS statements</p>
<p><code>select dbms_stats.create_extended_stats (NULL,'TEST_TAB','(corr_gr1_col1,corr_gr1_col2,corr_gr2_col4,corr_gr2_col5,corr_gr2_col6)') from dual ;</code><br />
<code>select dbms_stats.create_extended_stats (NULL,'TEST_TAB','(corr_gr1_col1,corr_gr1_col2,corr_gr2_col</code><br />
<code>*</code><br />
<code>ERROR at line 1:</code><br />
<code>ORA-20008: Number of extensions in table SCOTT.TEST_TAB already reaches the</code><br />
<code>upper limit (20</code><br />
<code><code>ORA-06512: at "SYS.DBMS_STATS", line 8415</code><br />
<code>ORA-06512: at "SYS.DBMS_STATS", line 32587</code></code></p>
<p>We can now score each column group and decide whnich ones will remain and which ones will be dropped.</p>
<p><code>select (count(distinct(corr_gr1_col1) ) * count(distinct(corr_gr1_col3)))/count(distinct(sys_op<br />
<code>_combined_hash(corr_gr1_col1,corr_gr1_col3))) from TEST_TAB ;</code></code></p>
<p><code>(COUNT(DISTINCT(CORR_GR1_COL1))*COUNT(DISTINCT(CORR_GR1_COL3)))/COUNT(DISTINCT(S</code></p>
<p><code>--------------------------------------------------------------------------------</code></p>
<p><code>50</code></p>
<p>&#8230; a few column group queries</p>
<p><code> select (count(distinct(corr_gr1_col1) ) * count(distinct(corr_gr2_col4)))/count(distinct(sys_op<br />
_combined_hash(corr_gr1_col1,corr_gr2_col4))) from TEST_TAB ;<br />
<code>(COUNT(DISTINCT(CORR_GR1_COL1))*COUNT(DISTINCT(CORR_GR2_COL4)))/COUNT(DISTINCT(S<br />
<code>--------------------------------------------------------------------------------<br />
<code>1</code></code></code></code></p>
<p>The column group (corr_gr1_col1,corr_gr2_col4) does not add any value to the CBO, so we can drop it and create  (corr_gr1_col1,corr_gr1_col2,corr_gr2_col4,corr_gr2_col5,corr_gr2_col6) instead.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/320/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=320&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2012/10/28/ora-20008-number-of-extensions-what-to-do-about-this-unnecessary-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
		<item>
		<title>NYOUG Sept. 2012 &#8211; Reduce Your Disk Footprint by Sharing Read-Only Tablespaces</title>
		<link>http://iiotzov.wordpress.com/2012/09/13/nyoug-sept-2012-reduce-your-disk-footprint-by-sharing-read-only-tablespaces/</link>
		<comments>http://iiotzov.wordpress.com/2012/09/13/nyoug-sept-2012-reduce-your-disk-footprint-by-sharing-read-only-tablespaces/#comments</comments>
		<pubDate>Thu, 13 Sep 2012 20:43:17 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Resource Management]]></category>
		<category><![CDATA[benefits of read-only tablespace]]></category>
		<category><![CDATA[datafile DBID read-only files]]></category>
		<category><![CDATA[reduce disk usage by sharing oracle]]></category>
		<category><![CDATA[save disk non-production oracle]]></category>
		<category><![CDATA[save disk oracle]]></category>
		<category><![CDATA[share datafile oracle]]></category>
		<category><![CDATA[share read only tablespace]]></category>
		<category><![CDATA[share read-only tablespace TTS]]></category>
		<category><![CDATA[share tablespace oracle]]></category>
		<category><![CDATA[transportable tablespace share RO tablespace]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=308</guid>
		<description><![CDATA[Thanks to all who attended my presentation (Reduce Your Disk Footprint by Sharing Read-Only Tablespaces) at NYOUG. We had a great discussion! The Power Point slides are here – I did some animation, so this is the best way to look at the presentation. Here is the PDF version of the slides. The white paper [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=308&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Thanks to all who attended my presentation (Reduce Your Disk Footprint by Sharing Read-Only Tablespaces)</p>
<p>at NYOUG.</p>
<p>We had a great discussion!</p>
<p>The Power Point slides are <a href="http://iiotzov.files.wordpress.com/2012/09/iotzov_sharerotablespaces_presentation_final.ppsx">here </a>– I did some animation, so this is the best way to look at the presentation. <a href="http://iiotzov.files.wordpress.com/2012/09/iotzov_sharerotablespaces_presentation_final.pdf">Here </a>is the PDF version of the slides. The white paper is <a href="http://iiotzov.files.wordpress.com/2012/09/iotzovsharerotablespaces.docx">here </a>- it is much more detailed than the presentation.</p>
<p>If you think that the non-supported universal method can save you disk space, feel free to call Oracle and ask them to take a look at it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/308/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=308&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2012/09/13/nyoug-sept-2012-reduce-your-disk-footprint-by-sharing-read-only-tablespaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Use the New OEM 12c Metric Extensions to Enforce Enterprise-Wide Custom Policies</title>
		<link>http://iiotzov.wordpress.com/2012/08/08/how-to-use-the-new-oem-12c-metric-extensions-to-enforce-enterprise-wide-custom-policies/</link>
		<comments>http://iiotzov.wordpress.com/2012/08/08/how-to-use-the-new-oem-12c-metric-extensions-to-enforce-enterprise-wide-custom-policies/#comments</comments>
		<pubDate>Wed, 08 Aug 2012 18:32:23 +0000</pubDate>
		<dc:creator>iiotzov</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Enterprise Manager]]></category>
		<category><![CDATA[Resource Management]]></category>
		<category><![CDATA[Enforce Enterprise-Wide Policies OEM]]></category>
		<category><![CDATA[Metric Extensions OEM12c]]></category>
		<category><![CDATA[Metric Extensions User Defined Metrics]]></category>
		<category><![CDATA[OEM]]></category>
		<category><![CDATA[OEM 12c]]></category>
		<category><![CDATA[Oracle Enterprise Manager Repository]]></category>
		<category><![CDATA[User Defined Metrics OEM12c]]></category>

		<guid isPermaLink="false">http://iiotzov.wordpress.com/?p=284</guid>
		<description><![CDATA[Oracle Enterprise Manager&#8217;s User-Defined Metrics (UDMs) were a very suitable vehicle for enforcing enterprise-wide policies. My NYOUG 2011/VirtaThon presentation and white paper contain a comprehensive example &#8211; monitoring forced logging status of all production databases. Since UDMs are gone in OEM 12c, we’ll see how to use Metric Extensions, the successor of UDMs, to accomplish [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=284&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Oracle Enterprise Manager&#8217;s User-Defined Metrics (UDMs) were a very suitable vehicle for enforcing enterprise-wide policies. My NYOUG 2011/VirtaThon <a href="http://iiotzov.files.wordpress.com/2011/08/iotzov_oem_repository.pdf">presentation</a> and <a href="http://iiotzov.files.wordpress.com/2012/05/oem-repository-a-second-look.doc">white paper</a> contain a comprehensive example &#8211; monitoring forced logging status of all production databases.</p>
<p>Since UDMs are gone in OEM 12c, we’ll see how to use Metric Extensions, the successor of UDMs, to accomplish the same goal.</p>
<p>Metric Extensions (MEs) represent a major improvement over UDMs in terms of code maintenance and ability to deploy to large number of targets. MEs, however, do not allow us to customize the SQL query for a specific target. Even though there is a good reason behind the behavior, it requires us to substantially change the architecture we have previously used.</p>
<p>In <a href="http://iiotzov.files.wordpress.com/2011/08/iotzov_oem_repository.pdf">the original presentation</a>, I used one UDM ( ForcedLogging ) that had different definitions for different targets.</p>
<p>In OEM 12c, we&#8217;ll need to have different Metric Extensions for each of the definitions and target types.</p>
<p>For most single instance DB targets, we&#8217;ll use the standard &#8220;ForcedLogging&#8221; ME that is defined with this query:</p>
<p><code><br />
select force_logging from v$database<br />
<code></code></code></p>
<p>For most RAC DB targets, we&#8217;ll use &#8220;ForcedLoggingRAC&#8221; ME that is defined with the same query:</p>
<p><code><br />
select force_logging from v$database<br />
<code></code></code></p>
<p>And if we want to ignore the “force logging” status of a database, then we can use ForcedLoggingIgnore&#8221; ME defined with this query:</p>
<p><code><br />
select 'YES' from v$database<br />
<code></code></code></p>
<p>The query/Metalized View that actually enforces the enterprise-wide force logging policy gets a little more complex:</p>
<p><code><br />
CREATE MATERIALIZED VIEW "SYSMAN"."UDM_FORCED_LOGGING" ("CNT") ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "MGMT_TABLESPACE" BUILD IMMEDIATE USING INDEX REFRESH COMPLETE ON DEMAND START WITH sysdate+0 NEXT SYSDATE + 1/96 USING DEFAULT LOCAL ROLLBACK SEGMENT USING ENFORCED CONSTRAINTS DISABLE QUERY REWRITE<br />
AS<br />
SELECT COUNT( member_target_guid ) cnt<br />
FROM SYSMAN.MGMT$GROUP_DERIVED_MEMBERSHIPS O ,<br />
SYSMAN.MGMT$TARGET T ,<br />
sysman.MGMT$AVAILABILITY_CURRENT st<br />
WHERE o.composite_target_name = 'PRODUCTION'<br />
AND o.member_target_type     IN ('oracle_database', 'rac_database')<br />
AND ( t.target_type           ='rac_database'<br />
OR (t.target_type             ='oracle_database'<br />
AND t.type_qualifier3        != 'RACINST'))<br />
AND o. member_target_guid     = t.target_guid<br />
AND t.target_guid             = st.target_guid<br />
AND st.availability_status    = 'Target Up'<br />
AND (NOT EXISTS<br />
(SELECT *<br />
FROM sysman.mgmt$metric_current i<br />
WHERE I.TARGET_GUID      = O.MEMBER_TARGET_GUID<br />
AND metric_name          = 'ME$ForcedLogging'<br />
AND column_label         = 'ForcedLogging'<br />
AND Metric_Column        = 'ForcedLogging'<br />
AND collection_timestamp &gt; sysdate - 30/1440<br />
AND value                = 'YES'<br />
)<br />
AND NOT EXISTS<br />
(SELECT *<br />
FROM sysman.mgmt$metric_current i<br />
WHERE i.target_guid      = o.member_target_guid<br />
AND metric_name          = 'ME$ForcedLoggingRAC'<br />
AND column_label         = 'ForcedLogging'<br />
AND Metric_Column        = 'ForcedLogging'<br />
AND collection_timestamp &gt; sysdate - 30/1440<br />
AND value                = 'YES'<br />
)<br />
AND NOT EXISTS<br />
(SELECT *<br />
FROM sysman.mgmt$metric_current i<br />
WHERE i.target_guid      = o.member_target_guid<br />
AND metric_name          = 'ME$ForcedLoggingIgnore'<br />
AND column_label         = 'ForcedLogging'<br />
AND Metric_Column        = 'ForcedLogging'<br />
AND collection_timestamp &gt; sysdate - 30/1440<br />
AND value                = 'YES'<br />
));<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iiotzov.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iiotzov.wordpress.com/284/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iiotzov.wordpress.com&#038;blog=24240018&#038;post=284&#038;subd=iiotzov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iiotzov.wordpress.com/2012/08/08/how-to-use-the-new-oem-12c-metric-extensions-to-enforce-enterprise-wide-custom-policies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/34580e236d6141fbc719d695602f7c84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">iiotzov</media:title>
		</media:content>
	</item>
	</channel>
</rss>
