<?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>Oracle Scratchpad</title>
	<atom:link href="http://jonathanlewis.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Tue, 21 May 2013 19:07:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jonathanlewis.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Oracle Scratchpad</title>
		<link>http://jonathanlewis.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jonathanlewis.wordpress.com/osd.xml" title="Oracle Scratchpad" />
	<atom:link rel='hub' href='http://jonathanlewis.wordpress.com/?pushpress=hub'/>
		<item>
		<title>UKOUG</title>
		<link>http://jonathanlewis.wordpress.com/2013/05/17/ukoug-2/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/05/17/ukoug-2/#comments</comments>
		<pubDate>Fri, 17 May 2013 14:25:38 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10974</guid>
		<description><![CDATA[The call for papers is open for Tech 13 &#8211; the &#8220;server-side&#8221; conference of the UKOUG. The conference was getting so big that we&#8217;ve split Apps from Server Tech and will be running the two conferences separately this year. The Server Tech conference will be in Manchester from 2nd to 4th Dec. The closing date [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10974&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The call for papers is <a href="http://www.tech13.ukoug.org/papers"><em><strong>open for Tech 13</strong></em></a> &#8211; the &#8220;server-side&#8221; conference of the UKOUG.</p>
<p>The conference was getting so big that we&#8217;ve split Apps from Server Tech and will be running the two conferences separately this year. The Server Tech conference will be in Manchester from 2nd to 4th Dec.</p>
<p>The closing date for submissions is Friday 31st May (only 2 weeks !) and confirmation of acceptance given by August.</p>
<p>There is a slightly <a href="http://www.tech13.ukoug.org/speakerapp"><em><strong>shorter route to submission</strong></em></a> (if you don&#8217;t want to watch the video on &#8220;Why to speak&#8221;).</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10974/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10974&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/05/17/ukoug-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
		<item>
		<title>Performance Monitoring</title>
		<link>http://jonathanlewis.wordpress.com/2013/05/16/performance-monitoring/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/05/16/performance-monitoring/#comments</comments>
		<pubDate>Thu, 16 May 2013 04:51:00 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10896</guid>
		<description><![CDATA[Updated &#8211; just a quick reminder for next week; I&#8217;ll be doing a short webinar next Wednesday comparing the performance monitoring tools Oracle and SQL server provide. I think I may have broken my record with 6 countries in 6 weeks &#8211; so I haven&#8217;t been very thorough at updating my blog recently. Just time, [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10896&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><span style="text-decoration:underline;"><strong>Updated</strong></span> &#8211; just a quick reminder for next week; I&#8217;ll be doing <a href="http://www.red-gate.com/products/oracle-development/deployment-suite-for-oracle/education/webinars/webinar-oracle-sql-server-performance-monitoring"><em><strong>a short webinar next Wednesday</strong> </em></a>comparing the performance monitoring tools Oracle and SQL server provide.</p>
<p>I think I may have broken my record with 6 countries in 6 weeks &#8211; so I haven&#8217;t been very thorough at updating my blog recently. Just time, before I head off to Heathrow once again, to do a quick advert for the next redgate webinar that I&#8217;m doing with Grant Fritchey. This time comparing built-in performance monitoring tools. Details and Registrations <a href="http://www.red-gate.com/products/oracle-development/deployment-suite-for-oracle/education/webinars/webinar-oracle-sql-server-performance-monitoring"><em><strong>at this URL</strong></em></a>.</p>
<p>I&#8217;ll see if I can catch up with a couple of answers while I&#8217;m in the airport lounge &#8211; but no promises, since the simple act of walking into an airport makes me  feel like falling asleep.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10896/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10896/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10896&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/05/16/performance-monitoring/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
		<item>
		<title>Webinars</title>
		<link>http://jonathanlewis.wordpress.com/2013/05/16/webinars/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/05/16/webinars/#comments</comments>
		<pubDate>Thu, 16 May 2013 04:47:06 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Advertisements]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10913</guid>
		<description><![CDATA[Reminder: The webinars on &#8220;Smarter Statistics in 11g&#8221; are on tomorrow (Friday) at 2:00 pm and 6:00 pm. There&#8217;s a waiting list for the 6:00 pm event, so if you&#8217;ve signed up but can&#8217;t make it please delete your registration. (The event will be repeated on 10th June).  If you want to vote a better [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10913&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>Reminder:</h3>
<p>The webinars on &#8220;Smarter Statistics in 11g&#8221; are on tomorrow (Friday) at 2:00 pm and 6:00 pm. There&#8217;s a waiting list for the 6:00 pm event, so if you&#8217;ve signed up but can&#8217;t make it please delete your registration. (The event will be repeated on 10th June).  If you want to vote a better time for me to do short webinars there&#8217;s a poll at the end of the article.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>I&#8217;m about to make a serious move into online webinars, and as a warm-up exercise I&#8217;ll be doing a couple of one-hour free events on Friday 17th May.</p>
<p>I&#8217;ll be talking through a Powerpoint presentation called &#8220;Smarter Statistics in 11g&#8221; twice, <a href="http://www.eventbrite.com/event/5411686500#"><em><strong>once at 2:00 pm &#8211; 3:00 pm BST</strong></em></a>, and again at 6:00 pm BST  <a href="http://www.eventbrite.com/event/6558832645#"><em><strong>(12:00 pm - 1:00 pm CDT)</strong></em></a> . Broadly speaking the first one is for the benefit people from the UK and eastwards, and the second is for the benefit of people from the US and westwards. This is just a trial run, of course, and if it works well I will be doing more of the same, perhaps three times per day to spread across more time zones.</p>
<p>John Goodhue (my O1 sponsor for the USA) is arranging all the mechanical details, and I&#8217;ll post links for registration when they become available &#8211; we&#8217;ll be using GoToWebinar as the supply mechanism, and we&#8217;ll be limiting access to 100 people (so if you do register and can&#8217;t attend, please remove yourself from the list; if you don&#8217;t manage to register for either event, you&#8217;ll get another chance later as I plan to repeat each event a few times.)</p>
<p>I&#8217;ll also be doing a full day paid event on 23rd May which will be my <a href="http://jonathanlewis.wordpress.com/public-appearances/tutorials/indexing-strategies/"><em><strong>&#8220;Indexing Strategies&#8221;</strong></em></a> tutorial. This first full day event will be timed to suit the American audience &#8211; although anyone can register, of course &#8211; but we plan to have further events suited to other time zones. The URL for registration <a href="http://www.eventbrite.com/event/6518945341%23#"><em><strong>is now available</strong></em></a> &#8211; with an option to purchase a 30-day window to the recording of my &#8220;Oracle Mechanisms&#8221; presentation in Minneapolis.</p>
<a name="pd_a_7096593"></a>
<div class="PDS_Poll" id="PDI_container7096593" data-settings="{&quot;url&quot;:&quot;http:\/\/static.polldaddy.com\/p\/7096593.js&quot;}" style="display:inline-block;"></div>
<div id="PD_superContainer"></div>
<noscript><a href="http://polldaddy.com/poll/7096593">Take Our Poll</a></noscript>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10913/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10913/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10913&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/05/16/webinars/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
		<item>
		<title>Parse Time</title>
		<link>http://jonathanlewis.wordpress.com/2013/05/13/parse-time/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/05/13/parse-time/#comments</comments>
		<pubDate>Mon, 13 May 2013 18:59:34 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Execution plans]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10943</guid>
		<description><![CDATA[Dominic Brooks published a note recently about some very nasty SQL &#8211; originally thinking that it was displaying a run-time problem due to the extreme number of copies of the lnnvl() function the optimizer had produced. In fact it turned out to be a parse-time problem rather than a run-time problem, but when I first read [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10943&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Dominic Brooks published a note recently about some <a href="http://orastory.wordpress.com/2013/04/05/ors-in-lists-and-lnnvl"><em><strong>very nasty SQL</strong></em></a> &#8211; originally thinking that it was displaying a run-time problem due to the extreme number of copies of the <em><strong>lnnvl()</strong></em> function the optimizer had produced. In fact it turned out to be a parse-time problem rather than a run-time problem, but when I first read Dominic&#8217;s note I was sufficiently surprised that I decided to try modelling the query.</p>
<p>Unfortunately the query had more than 1,000 predicates, (OR&#8217;ed together) and some of them included in-lists.  Clearly, writing this up by hand wasn&#8217;t going to be a good idea, so I wrote a script to generate both the data, and the query, as follows &#8211; first a table to query:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
create table t1
as
with generator as (
	select	--+ materialize
		rownum id
	from dual
	connect by
		level &lt;= 1e4
)
select
	rownum		id1,
	rownum		id2,
	rownum		id,
	lpad(rownum,10)	v1,
	rpad('x',100)	padding
from
	generator	v1,
	generator	v2
where
	rownum &lt;= 1e5
;

create index t1_i1 on t1(id1, id2);

begin
	dbms_stats.gather_table_stats(
		ownname		 =&gt; user,
		tabname		 =&gt;'T1',
		method_opt	 =&gt; 'for all columns size 1'
	);
end;
/

</pre>
<p>Then a piece of code to write a nasty query:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
set pagesize 0
set feedback off
set termout off

spool temp1.sql

prompt select * from t1 where 1 = 2

select
	'or (id1 = ' || rownum || ' and id2 = ' || (rownum + 1) || ')'
from
	t1
where
	rownum &lt;= 750
union all
select
	'or ( id1 =  ' || (rownum + 1000) || ' and id2 in (' || rownum || ',' || (rownum+1) || '))'
from
	t1
where
	rownum &lt;= 250
;

prompt /

spool off

</pre>
<p>Here&#8217;s an example of the text generated by the code &#8211; with the parameters set to 5 and 3 respectively (and notice how I&#8217;ve rigged the query so that it doesn&#8217;t return any data, whatever the optimizer thinks):</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
select * from t1 where 1 = 2
or (id1 = 1 and id2 = 2)
or (id1 = 2 and id2 = 3)
or (id1 = 3 and id2 = 4)
or (id1 = 4 and id2 = 5)
or (id1 = 5 and id2 = 6)
or ( id1 =  1001 and id2 in (1,2))
or ( id1 =  1002 and id2 in (2,3))
or ( id1 =  1003 and id2 in (3,4))
/
</pre>
<p>So here&#8217;s the plan from the above query:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">

---------------------------------------------------------------------------------------
| Id  | Operation                     | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT              |       |     8 |  1008 |    16   (0)| 00:00:01 |
|   1 |  CONCATENATION                |       |       |       |            |          |
|   2 |   TABLE ACCESS BY INDEX ROWID | T1    |     1 |   126 |     3   (0)| 00:00:01 |
|*  3 |    INDEX RANGE SCAN           | T1_I1 |     1 |       |     2   (0)| 00:00:01 |
|   4 |   TABLE ACCESS BY INDEX ROWID | T1    |     1 |   126 |     3   (0)| 00:00:01 |
|*  5 |    INDEX RANGE SCAN           | T1_I1 |     1 |       |     2   (0)| 00:00:01 |
|   6 |   TABLE ACCESS BY INDEX ROWID | T1    |     1 |   126 |     3   (0)| 00:00:01 |
|*  7 |    INDEX RANGE SCAN           | T1_I1 |     1 |       |     2   (0)| 00:00:01 |
|   8 |   INLIST ITERATOR             |       |       |       |            |          |
|   9 |    TABLE ACCESS BY INDEX ROWID| T1    |     5 |   630 |     7   (0)| 00:00:01 |
|* 10 |     INDEX RANGE SCAN          | T1_I1 |     5 |       |     6   (0)| 00:00:01 |
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - access(&quot;ID1&quot;=1003)
       filter(&quot;ID2&quot;=3 OR &quot;ID2&quot;=4)
   5 - access(&quot;ID1&quot;=1002)
       filter((LNNVL(&quot;ID1&quot;=1003) OR LNNVL(&quot;ID2&quot;=3) AND LNNVL(&quot;ID2&quot;=4)) AND
              (&quot;ID2&quot;=2 OR &quot;ID2&quot;=3))
   7 - access(&quot;ID1&quot;=1001)
       filter((LNNVL(&quot;ID1&quot;=1002) OR LNNVL(&quot;ID2&quot;=2) AND LNNVL(&quot;ID2&quot;=3)) AND
              (LNNVL(&quot;ID1&quot;=1003) OR LNNVL(&quot;ID2&quot;=3) AND LNNVL(&quot;ID2&quot;=4)) AND (&quot;ID2&quot;=1 OR
              &quot;ID2&quot;=2))
  10 - access((&quot;ID1&quot;=1 AND &quot;ID2&quot;=2 OR &quot;ID1&quot;=2 AND &quot;ID2&quot;=3 OR &quot;ID1&quot;=3 AND
              &quot;ID2&quot;=4 OR &quot;ID1&quot;=4 AND &quot;ID2&quot;=5 OR &quot;ID1&quot;=5 AND &quot;ID2&quot;=6))
       filter((LNNVL(&quot;ID1&quot;=1001) OR LNNVL(&quot;ID2&quot;=1) AND LNNVL(&quot;ID2&quot;=2)) AND
              (LNNVL(&quot;ID1&quot;=1002) OR LNNVL(&quot;ID2&quot;=2) AND LNNVL(&quot;ID2&quot;=3)) AND
              (LNNVL(&quot;ID1&quot;=1003) OR LNNVL(&quot;ID2&quot;=3) AND LNNVL(&quot;ID2&quot;=4)))

</pre>
<p>As you can see, the first five predicates end up in line 10 of the plan with 10 repetitions (5 * 2) of the lnnvl() function. The last three predicates show up in lines 3, 5, and 7 &#8211; and the on each line we see two more lnnvl() calls than on the previous &#8211; just imagine, then, how many lnnvl() calls the optimizer will have added to the query plan by the time we have 750 occurrences in the inlist iterator (line 8) and 250 occurrences of the slightly complex predicate. Here are the relevant CPU stats (from v$session_stats) from running the generated script on 11.1.0.7, on Windows 32-bit, 2.8GHz CPU:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
Name                                           Value
----                                           -----
recursive cpu usage                            1,848
CPU used when call started                     1,854
CPU used by this session                       1,854
DB time                                        1,870
parse time cpu                                 1,847
parse time elapsed                             1,862

</pre>
<p>Clearly the parse time is extreme &#8211; though not as dramatic as in Dominic&#8217;s example; but having set up the first draft of the sample code it&#8217;s easy enough to change the number of occurrences of each type of predicate, and it&#8217;s pretty easy to make longer in-lists in the more complex of the two types of predicate. It&#8217;s not too difficult to get an execution plan that mimics Dominic&#8217;s in length and time to parse.</p>
<p>It&#8217;s not just the parse times that are interesting when you start doing this, by the way &#8211; it&#8217;s worth playing around to see what happens. It&#8217;s probably best to run the query to pull the plans from memory if you want to see the plans, though &#8211; if you try using &#8220;explain plan&#8221; then you start using memory in the SGA for some of the work: in one of my examples I had to abort the instance after a few minutes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10943/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10943/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10943&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/05/13/parse-time/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
		<item>
		<title>ISS</title>
		<link>http://jonathanlewis.wordpress.com/2013/05/13/iss/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/05/13/iss/#comments</comments>
		<pubDate>Mon, 13 May 2013 18:45:49 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Non-technical]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10958</guid>
		<description><![CDATA[I&#8217;d like to dedicate this posting to fellow Oak Table member Richard Foote, for reasons that the readers we have in common will immediately recognise: http://www.youtube.com/watch?v=KaOC9danxNo The singer is Canadian astronaut Commander Chris Hadfield who has been tweeting and posting pictures from space &#8211; be careful, you may get hooked: https://twitter.com/Cmdr_Hadfield/status/332819772989378560/photo/1 Update: When I posted the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10958&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I&#8217;d like to dedicate this posting to fellow Oak Table member <a href="http://richardfoote.wordpress.com/"><em><strong>Richard Foote</strong></em></a>, for reasons that the readers we have in common will immediately recognise: <a href="http://www.youtube.com/watch?v=KaOC9danxNo">http://www.youtube.com/watch?v=KaOC9danxNo</a></p>
<p>The singer is Canadian astronaut Commander Chris Hadfield who has been tweeting and posting pictures from space &#8211; be careful, you may get hooked: <a href="https://twitter.com/Cmdr_Hadfield/status/332819772989378560/photo/1">https://twitter.com/Cmdr_Hadfield/status/332819772989378560/photo/1</a></p>
<h3>Update:</h3>
<p>When I posted the link to the video it had received 1.5M views; less than 24 hours later it&#8217;s up to roughly 7M. (And they weren&#8217;t all Richard Foote). Clearly the images have caught the imagination of a lot of people. If you have looked at the twitter stream it&#8217;s equally inspiring &#8211; and not just for the pictures.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10958/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10958/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10958&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/05/13/iss/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
		<item>
		<title>Hakan Factor</title>
		<link>http://jonathanlewis.wordpress.com/2013/05/10/hakan-factor/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/05/10/hakan-factor/#comments</comments>
		<pubDate>Fri, 10 May 2013 15:52:24 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10938</guid>
		<description><![CDATA[Here&#8217;s a quick and dirty script to create a procedure (in the SYS schema &#8211; so be careful) to check the Hakan Factor for an object. If you&#8217;re not familiar with the Hakan Factor, it&#8217;s the value that gets set when you use the command &#8220;alter table minimize records_per_block;&#8221;. I was prompted to publish this [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10938&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s a quick and dirty script to create a procedure (in the SYS schema &#8211; so be careful) to check the Hakan Factor for an object. If you&#8217;re not familiar with the Hakan Factor, it&#8217;s the value that gets set when you use the command &#8220;alter table minimize records_per_block;&#8221;.</p>
<p>I was prompted to publish this note by an item on the OTN SQL forum describing a problem with partition exchange with a table when there were bitmap indexes in place and the table had been changed to have some extra columns added. (Problem as yet unresolved as I publish).</p>
<p>If you start playing with the Hakan Factor, you&#8217;ll find that there are some odd little bugs in what gets stored and how it gets used. (SQL updated to use bitand() to reflect comments below and Karsten Spang&#8217;s blog note; also edited following a comment on OTN to show the rest of the spare1 flag bits)</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">

create or replace procedure show_hakan(
	i_table		in	varchar2,
	i_owner		in	varchar2 default user
) as
	m_obj		number(8,0);
	m_flags		varchar2(12);
	m_hakan		number(8,0);
begin

	/* created by show_hakan.sql	*/
	select
		obj#, 
/*
		case 
			when	(spare1 &gt; 5 * power(2,15)) 
				then	(spare1 - 5 * power(2,15))
			when	(spare1 &gt; power(2,17)) 
				then	(spare1 - power(2,17))
			when	(spare1 &gt; power(2,15)) 
				then	(spare1 - power(2,15))
				else	spare1
		end 				hakan
*/
	to_char(
		bitand(
			spare1, to_number('ffff8000','xxxxxxxx')
		),
		'xxxxxxxx'
	)					flags,
	bitand(spare1, 32767)			hakan	-- 0x7fff	
	into
		m_obj,
		m_flags,
		m_hakan
	from
		tab$
	where	obj# in (
			select	object_id 
			from	dba_objects
			where	object_name = upper(i_table)
			and	object_type = 'TABLE'
			and	owner = upper(i_owner)
		)
	;

	dbms_output.put_line(
		'Hakan factor for object ' || 
		m_obj   || ' (' ||
		i_owner || '.' || 
		i_table || ') is ' || 
		m_hakan || ' with flags ' ||
		m_flags
	);
end;
/

drop public synonym show_hakan;
create public synonym show_hakan for show_hakan;
grant execute on show_hakan to public;

</pre>
<p>&nbsp;</p>
<p>You&#8217;ll notice that I&#8217;ve done an &#8220;upper()&#8221; on the table and owner &#8211; that means you&#8217;re in trouble if you have created an schemas or tables with mixed-case names (but you wouldn&#8217;t do that in a production system, would you?)</p>
<h3>Update &#8211; A little bug history</h3>
<p>One of the odd details of the Hakan factor is that the value it shows is one less than the number of rows that will be stored in a block; and since it looks as if the factor is not allowed to drop to zero, you can&#8217;t hack the Hakan factor to force one row per block.</p>
<p>So here&#8217;s a (trivial and sub-optimal) piece of code to check current number of rows per block in a simple heap table (assuming the tablespace consists of a single file):</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
select 
	ct, count(*) 
from	(
		select	dbms_rowid.rowid_block_number(rowid), count(*) ct  
		from	t1
		group by
			dbms_rowid.rowid_block_number(rowid)
	)
group by ct
order by ct
;

</pre>
<p>Here&#8217;s the output of a session, running under 9.2.0.8, cut and pasted from the screen:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
SQL&gt; @afiedt.buf

        CT   COUNT(*)
---------- ----------
         9          1
        16          1
SQL&gt; alter table t1 nominimize records_per_block;
SQL&gt; alter table t1 minimize records_per_block;
SQL&gt; execute show_hakan('t1')
Hakan factor for object 48865 (TEST_USER.t1) is: 15
SQL&gt; alter table t1 move;
SQL&gt; @afiedt.buf

        CT   COUNT(*)
---------- ----------
        10          1
        15          1
SQL&gt; alter table t1 nominimize records_per_block;
SQL&gt; alter table t1 minimize records_per_block;
SQL&gt; execute show_hakan('t1')
Hakan factor for object 48865 (TEST_USER.t1) is: 14
</pre>
<p>Every time you moved the table, 9.2.0.8 (and earlier) used the actual stored value of the Hakan Factor to rebuild the table; but if you regenerated the Hakan Factor the stored value was one less than the actual row count. So if you kept repeating the process the number of rows per block would decrease by one each time and the table would get bigger and bigger.</p>
<p>It&#8217;s a silly example &#8211; but the real-world relevance was that a direct path insert behaved differently from a normal insert and this could result in a significant amount of wasted space if you were doing bulk loads in your overnight batch; so the code changed in 10g to make the normal and direct path inserts consistent with each other, but the change went the wrong way and, as a side effect, you get one more row per block than suggested by the Hakan Factor &#8211; and you can&#8217;t trick the Hakan factor into enforcing one row per block any more.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10938/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10938/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10938&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/05/10/hakan-factor/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
		<item>
		<title>Clustering_factor</title>
		<link>http://jonathanlewis.wordpress.com/2013/05/09/clustering_factor-2/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/05/09/clustering_factor-2/#comments</comments>
		<pubDate>Thu, 09 May 2013 08:14:00 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[CBO]]></category>
		<category><![CDATA[Indexing]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10675</guid>
		<description><![CDATA[Cost Based Oracle &#8211; Fundamentals (November 2005) But the most interesting function for our purposes is sys_op_countchg(). Judging from its name, this function is probably counting changes, and the first input parameter is the block ID portion (object_id, relative file number, and block number) of the table’s rowid, so the function is clearly matching our [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10675&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Cost Based Oracle &#8211; Fundamentals (November 2005)</p>
<blockquote><p><em>But the most interesting function for our purposes is sys_op_countchg(). Judging from its name, this function is probably counting changes, and the first input parameter is the block ID portion (object_id, relative file number, and block number) of the table’s rowid, so the function is clearly matching our notional description of how the clustering_factor is calculated. But what is that 1 we see as the second parameter?</em></p>
<p><em>When I first understood how the clustering_factor was defined, I soon realized that its biggest flaw was that Oracle wasn’t remembering recent history as it walked the index; it only remembered the previous table block so that it could check whether the latest row was in the same table block as last time or in a new table block. So when I saw this function, my first guess (or hope) was that the second parameter was a method of telling Oracle to remember a list of previous block visits as it walked the index.</em></p></blockquote>
<p>And finally, Oracle Corp. had implemented an official interface to the second parameter of <em><strong>sys_op_countchg()</strong></em> &#8211; provided you install the right patch &#8211; through a new table (or schema, or database) preference type available to the <em><strong>dbms_stats.set_table_prefs()</strong></em> procedure.</p>
<p>I&#8217;ve been meaning to write this post for two or three months, ever since Sean Molloy sent me an email about short blog note from Martin Decker describing <em><strong><a href="http://www.ora-solutions.net/web/2013/02/22/index-clustering-factor-finally-more-realistic">Bug 13262857  Enh: provide some control over DBMS_STATS index clustering factor computation</a></strong>. </em>Unfortunately I&#8217;ve not yet had time to investigate the patch, but I don&#8217;t think I need to any more because Richard Foote has written it up in <a href="http://richardfoote.wordpress.com/2013/05/08/important-clustering-factor-calculation-improvement-fix-you/"><em><strong>his latest blog post</strong></em></a>.</p>
<p>Read Richard&#8217;s post &#8211; it&#8217;s important.</p>
<h2>Update 10th May</h2>
<p>Richard&#8217;s post has, unsurprisingly, produced a buzz of excitement in his reader &#8211; and started up the discussion of how best to use this capability; so here&#8217;s another quote from the book (p.111 &#8211; available in <a href="http://www.apress.com/downloadable/download/sample/sample_id/716/"><em><strong>the download of chapter 5</strong></em></a>):</p>
<blockquote><p><em>So using Oracle’s own function for calculating the <strong>clustering_factor</strong>, but substituting the <strong>freelists</strong> value for the table, may be a valid method for correcting some errors in the clustering_factor for indexes on strongly sequenced data. (The same strategy applies if you use multiple <strong>freelist groups</strong>—but multiply freelists by freelist groups to set the second parameter.)</em></p>
<p><em>Can a similar strategy be used to find a modified clustering_factor in other circumstances? I think the answer is a cautious “yes” for tables that are in <strong>ASSM</strong> tablespaces. Remember that Oracle currently allocates and formats 16 new blocks at a time when using automatic segment space management (even when the extent sizes are very large, apparently). This means that new data will be roughly scattered across groups of 16 blocks, rather than being tightly packed.</em></p>
<p><em>Calling Oracle’s <strong>sys_op_countchg()</strong> function with a parameter of 16 could be enough to produce a reasonable clustering_factor where Oracle currently produces a meaningless one. The value 16 should, however, be used as an upper bound. If your real <strong>degree of concurrency</strong> is typically less than 16, then your actual degree of concurrency would probably be more appropriate.</em></p>
<p><em>Whatever you do when experimenting with this function—don’t simply apply it across the board to all indexes, or even all indexes on a particular table. There will probably be just a handful of critical indexes where it is a good way of telling Oracle a little more of the truth about your system—in other cases you will simply be confusing the issue.</em></p></blockquote>
<p>Note particularly the comments about how the best value depends on the data in the indexed columns, the table configuration, and the degree of concurrency - you don&#8217;t necessarily want to use the same value for every index on a given table. That&#8217;s a shame, since Oracle has defined the interface as a TABLE preference, so if you set it then you get the same for every index. Despite this, if you&#8217;re prepared to put in a little control work, it does mean that you can use an official Oracle mechanism to play the game I was suggesting in the book &#8211; for each &#8220;special&#8221; index, set the preference, collect the stats, then clear the preference.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10675/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10675/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10675&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/05/09/clustering_factor-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
		<item>
		<title>SLOB</title>
		<link>http://jonathanlewis.wordpress.com/2013/05/05/slob/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/05/05/slob/#comments</comments>
		<pubDate>Sun, 05 May 2013 18:21:27 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10919</guid>
		<description><![CDATA[Anyone who has used Kevin Closson&#8217;s &#8220;Silly Little Oracle Benchmark&#8221; will want to know about his significantly updated SLOB2.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10919&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Anyone who has used Kevin Closson&#8217;s <a href="http://kevinclosson.wordpress.com/2012/05/13/quick-reference-readme-file-for-slob-the-silly-little-oracle-benchmark/"><em><strong>&#8220;Silly Little Oracle Benchmark&#8221;</strong></em></a> will want to know about his significantly updated <em><strong><a href="https://kevinclosson.wordpress.com/2013/05/02/slob-2-a-significant-update-links-are-here/">SLOB2</a>.</strong></em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10919/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10919/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10919&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/05/05/slob/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
		<item>
		<title>v$lock</title>
		<link>http://jonathanlewis.wordpress.com/2013/05/02/vlock/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/05/02/vlock/#comments</comments>
		<pubDate>Thu, 02 May 2013 19:03:05 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Locks]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10726</guid>
		<description><![CDATA[The problem of slow queries on v$lock just came up again on the OTN database forum, so I thought I&#8217;d better push out a post that&#8217;s been hanging around on my blog for the last few months. This is actually mentioned in MOS in note 1328789.1: &#8220;Query Against v$lock Run from OEM Performs Slowly&#8221; which [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10726&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The problem of slow queries on <em><strong>v$lock</strong></em> just came up again on the <a href="https://forums.oracle.com/forums/thread.jspa?threadID=2531607&amp;tstart=0"><em><strong>OTN database forum</strong></em></a>, so I thought I&#8217;d better push out a post that&#8217;s been hanging around on my blog for the last few months. This is actually mentioned in MOS in note 1328789.1: &#8220;Query Against v$lock Run from OEM Performs Slowly&#8221; which points out that it is basically a problem of bad statistics and all you have to do is collect the stats.</p>
<p>However, because the view is a messy union and join of several dynamic performance views sitting on top of a load of x$ structures, the advisory from MOS is to call the procedure  <em><strong>dbms_stats.gather_fixed_objects_stats</strong></em>. This is not a nice thing to do on a busy production system, especially if it has a large number of users and a large shared pool &#8211; and doing it at a representative run-time is important if you&#8217;re going to do it at all.</p>
<p>There is an alternative. Here&#8217;s the basic execution plan (on my 11.2.0.2) for <em>&#8220;select * from v$lock&#8221;</em>:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
-----------------------------------------------------
| Id  | Operation              | Name       | Rows  |
-----------------------------------------------------
|   0 | SELECT STATEMENT       |            |     1 |
|   1 |  HASH JOIN             |            |     1 |
|   2 |   VIEW                 | GV$_LOCK   |    10 |
|   3 |    UNION-ALL           |            |       |
|   4 |     FILTER             |            |       |
|   5 |      VIEW              | GV$_LOCK1  |     2 |
|   6 |       UNION-ALL        |            |       |
|   7 |        FIXED TABLE FULL| X$KDNSSF   |     1 |
|   8 |        FIXED TABLE FULL| X$KSQEQ    |     1 |
|   9 |     FIXED TABLE FULL   | X$KTADM    |     1 |
|  10 |     FIXED TABLE FULL   | X$KTATRFIL |     1 |
|  11 |     FIXED TABLE FULL   | X$KTATRFSL |     1 |
|  12 |     FIXED TABLE FULL   | X$KTATL    |     1 |
|  13 |     FIXED TABLE FULL   | X$KTSTUSC  |     1 |
|  14 |     FIXED TABLE FULL   | X$KTSTUSS  |     1 |
|  15 |     FIXED TABLE FULL   | X$KTSTUSG  |     1 |
|  16 |     FIXED TABLE FULL   | X$KTCXB    |     1 |
|  17 |   MERGE JOIN CARTESIAN |            |   100 |
|  18 |    FIXED TABLE FULL    | X$KSUSE    |     1 |
|  19 |    BUFFER SORT         |            |   100 |
|  20 |     FIXED TABLE FULL   | X$KSQRS    |   100 |
-----------------------------------------------------
</pre>
<p>Note, particularly, the Cartesian merge join at line 17, which assumes there will be one row from <em><strong>v$session</strong></em> (<em><strong>x$ksuse</strong></em>) joined to 100 rows from <em><strong>v$resource</strong></em> (<em><strong>x$ksqrs</strong></em> &#8211; the structure used to represent any resources that you want to lock). The big <em><strong>UNION ALL</strong></em> is then all the different types of locks (enqueues) that you might attach to a resource. The estimates relating to these two structures are the most significant problem &#8211; <em><strong>v$session</strong></em> always has FAR more than one row in it, and <em><strong>v$resource</strong></em> isn&#8217;t small: in my little system the Cartesian join produced about 325,000 rows, and that was just after starting up the database.</p>
<p>Having identified a couple of critical tables, I decided to see what would happen if I just collected stats on these two objects rather than doing the whole system, and the following little piece of pl/sql did what I wanted:</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
begin
        dbms_stats.gather_table_stats('SYS','x$ksuse',method_opt=&gt;'for all columns size 1');
        dbms_stats.gather_table_stats('SYS','x$ksqrs',method_opt=&gt;'for all columns size 1');
end;
/
</pre>
<p>The effect of the stats was to change the plan to the following which, while it might not be the absolute best in all cases, is certainly better than the previous one (it&#8217;s possible that you may also find that it helps to collect stats on <em><strong>x$ksqeq</strong></em> (the &#8220;generic enqueues&#8221; structure) which is likely to be the next most significant in terms of number of rows):</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
------------------------------------------------------
| Id  | Operation               | Name       | Rows  |
------------------------------------------------------
|   0 | SELECT STATEMENT        |            |   133 |
|   1 |  HASH JOIN              |            |   133 |
|   2 |   HASH JOIN             |            |    10 |
|   3 |    VIEW                 | GV$_LOCK   |    10 |
|   4 |     UNION-ALL           |            |       |
|   5 |      FILTER             |            |       |
|   6 |       VIEW              | GV$_LOCK1  |     2 |
|   7 |        UNION-ALL        |            |       |
|   8 |         FIXED TABLE FULL| X$KDNSSF   |     1 |
|   9 |         FIXED TABLE FULL| X$KSQEQ    |     1 |
|  10 |      FIXED TABLE FULL   | X$KTADM    |     1 |
|  11 |      FIXED TABLE FULL   | X$KTATRFIL |     1 |
|  12 |      FIXED TABLE FULL   | X$KTATRFSL |     1 |
|  13 |      FIXED TABLE FULL   | X$KTATL    |     1 |
|  14 |      FIXED TABLE FULL   | X$KTSTUSC  |     1 |
|  15 |      FIXED TABLE FULL   | X$KTSTUSS  |     1 |
|  16 |      FIXED TABLE FULL   | X$KTSTUSG  |     1 |
|  17 |      FIXED TABLE FULL   | X$KTCXB    |     1 |
|  18 |    FIXED TABLE FULL     | X$KSUSE    |   252 |
|  19 |   FIXED TABLE FULL      | X$KSQRS    |  1328 |
------------------------------------------------------

</pre>
<p>Thanks to Timur Akhmadeev who recently <em><strong><a href="http://timurakhmadeev.wordpress.com/2013/02/25/fixed-stats">published a note</a></strong></em> pointing out that you could collect stats on individual X$ tables. Do make sure you test this on your specific version of Oracle, though, and don&#8217;t use the production system as your first test case.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10726/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10726/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10726&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/05/02/vlock/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
		<item>
		<title>MV Refresh</title>
		<link>http://jonathanlewis.wordpress.com/2013/04/29/mv-refresh/</link>
		<comments>http://jonathanlewis.wordpress.com/2013/04/29/mv-refresh/#comments</comments>
		<pubDate>Mon, 29 Apr 2013 14:13:15 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=10899</guid>
		<description><![CDATA[Materialized views open up all sorts of possibilities for making reporting more efficient &#8211; but at the same time they can introduce some &#8220;interesting&#8221; side effects when you start seeing refreshes taking place. (Possibly one of the most dramatic surprises appeared in the upgrade that switched many refreshes into &#8220;atomic&#8221; mode, changing a &#8220;truncate / [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10899&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Materialized views open up all sorts of possibilities for making reporting more efficient &#8211; but at the same time they can introduce some &#8220;interesting&#8221; side effects when you start seeing refreshes taking place. (Possibly one of the most dramatic surprises appeared in the upgrade that switched many refreshes into &#8220;atomic&#8221; mode, changing a &#8220;truncate / append&#8221; cycle into a massively expensive &#8220;delete / insert&#8221; cycle).</p>
<p>If you want to have some ideas of the type of work that is involved in the materialized view &#8220;fast refresh&#8221;, you could look at a recent pair of articles by Alberto Dell&#8217;Era on (very specifically) outer join materialized views (which a link back to a much older article on inner join materialized view refresh):</p>
<ul>
<li><a href="http://www.adellera.it/blog/2009/08/04/fast-refresh-of-join-only-materialized-views-algorithm-summary/"><em><strong>(Inner) Join View refresh (2009)</strong></em></a></li>
<li><a href="http://www.adellera.it/blog/2013/04/22/fast-refresh-of-outer-join-only-materialized-views-algorithm-part-1/"><em><strong>Outer join view refresh part 1</strong></em></a></li>
<li><a href="http://www.adellera.it/blog/2013/04/29/fast-refresh-of-outer-join-only-materialized-views-algorithm-part-2/"><em><strong>Outer join view refresh part 2</strong></em></a></li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/10899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/10899/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=10899&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2013/04/29/mv-refresh/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Jonathan Lewis</media:title>
		</media:content>
	</item>
	</channel>
</rss>
