<?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 &#187; All Postings</title>
	<atom:link href="http://jonathanlewis.wordpress.com/all-postings/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Tue, 29 May 2012 13:25:25 +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 &#187; All Postings</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>Ch-ch-ch-ch-changes</title>
		<link>http://jonathanlewis.wordpress.com/2012/05/28/ch-ch-ch-ch-changes/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/05/28/ch-ch-ch-ch-changes/#comments</comments>
		<pubDate>Mon, 28 May 2012 17:31:40 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Index Rebuilds]]></category>
		<category><![CDATA[Indexing]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8961</guid>
		<description><![CDATA[For those not familiar with Richard Foote&#8217;s extensive blog about indexes (and if you&#8217;re not you should be) &#8211; the title of this note is a blatant hi-jacking of his preferred naming mechanism. It&#8217;s just a short note to remind myself (and my readers) that anything you know about Oracle, and anything published on the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8961&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For those not familiar with <a href="http://richardfoote.wordpress.com/"><em><strong>Richard Foote&#8217;s extensive blog</strong></em></a> about indexes (and if you&#8217;re not you should be) &#8211; the title of this note is a blatant hi-jacking of his preferred naming mechanism.</p>
<p>It&#8217;s just a short note to remind myself (and my readers) that anything you know about Oracle, and anything published on the Internet &#8211; even by Oracle Corp. and its employees &#8211; is subject to change without notice (and sometimes without being noticed). I came across one such change today while read the <a href="http://www.amazon.com/Expert-Oracle-Exadata-Kerry-Osborne/dp/1430233923"><em><strong>Expert Oracle Exadata</strong> </em></a>book by Kerry Osborne, Randy Johnson and Tanel Poder. It was just a little throwaway comment to the effect that:</p>
<p style="padding-left:30px;"><em>In NOARCHIVELOG mode all bulk operations (such as INSERT, APPEND, index REBUILD and ALTER TABLE MOVE) are automatically nologging.</em></p>
<p>The obvious error there is the reference to &#8220;index REBUILD&#8221;. Although <em><strong>create table as select</strong></em> and <em><strong>alter table move</strong> </em>default to nologging (when running in <strong>noarchivelog</strong> mode) the equivalent commands for indexes have always been logged. On the other hand, pausing for thought here, I wouldn&#8217;t expect such an obvious error to slip past all three authors and the technical reviewers so, before opening my mouth and putting my foot firmly into it, I decided to run a quick test and, almost inevitably, I have a handy test script that I&#8217;ve been running intermittently for years for exactly this test case.</p>
<p><pre class="brush: plain; gutter: false;">
execute snap_redo.start_snap

create table t1
as
with generator as (
	select	--+ materialize
		rownum id
	from dual
	connect by
		level &lt;= 10000
)
select
	rownum			id,
	lpad(rownum,10,'0')	small_vc,
	rpad('x',100)		padding
from
	generator	v1,
	generator	v2
where
	rownum &lt;= 100000
;

execute snap_redo.end_snap

execute snap_redo.start_snap
create index t1_i1 on t1(padding);
execute snap_redo.end_snap

execute snap_redo.start_snap
alter index t1_i1 rebuild;
execute snap_redo.end_snap

</pre></p>
<p>The <em><strong>snap_redo</strong></em> package is a simple bit of pl/sql I wrote to report the changes in a few of the current session stats (view <em><strong>v$mystat</strong></em>) over time. Specfically it looks at the statistics containing the word redo (and, in a more sophisticated form, a few others related to transaction management). Here are the key results for a test run on 10.2.0.3 and 11.1.0.7 &#8211; first from 10g</p>
<p><pre class="brush: plain; gutter: false;">
============
Create Table
============
redo synch writes                                                            2
redo entries                                                               410
redo size                                                               71,792
redo wastage                                                             1,836
redo writes                                                                  6
redo blocks written                                                        133
redo ordering marks                                                          3
redo subscn max counts                                                      10

============
Create Index
============
redo synch writes                                                            3
redo synch time                                                              2
redo entries                                                             1,887
redo size                                                           13,129,888
redo buffer allocation retries                                               4
redo wastage                                                             2,144
redo writes                                                                 11
redo blocks written                                                     26,428
redo write time                                                             67
redo log space requests                                                      3
redo log space wait time                                                    31
redo ordering marks                                                          3
redo subscn max counts                                                       3

=============
Rebuild index
=============
redo synch writes                                                            2
redo entries                                                             1,978
redo size                                                           13,132,052
redo buffer allocation retries                                               2
redo wastage                                                             4,084
redo writes                                                                 16
redo blocks written                                                     26,453
redo write time                                                             66
redo ordering marks                                                          3
redo subscn max counts                                                       4

</pre></p>
<p>Now from 11g</p>
<p><pre class="brush: plain; gutter: false;">
============
Create Table
============
redo synch writes                                                            1
redo synch time                                                              1
redo entries                                                               428
redo size                                                               67,228
redo size for direct writes                                              2,912
redo wastage                                                             1,072
redo writes                                                                  5
redo blocks written                                                        138
redo write time                                                              1
redo ordering marks                                                          3
redo subscn max counts                                                       5

============
Create Index
============
redo synch writes                                                            1
redo entries                                                               601
redo size                                                               71,092
redo size for direct writes                                             14,916
redo wastage                                                               972
redo writes                                                                  4
redo blocks written                                                        146
redo blocks checksummed by FG (exclusive)                                    6
redo ordering marks                                                          3
redo subscn max counts                                                       4

=============
Rebuild index
=============
redo synch writes                                                            1
redo entries                                                               684
redo size                                                               80,400
redo size for direct writes                                             14,916
redo wastage                                                             1,988
redo writes                                                                  7
redo blocks written                                                        167
redo write time                                                              5
redo blocks checksummed by FG (exclusive)                                    6
redo ordering marks                                                          4
redo subscn max counts                                                       5

</pre></p>
<p>As you can see, somewhere between 10.2.0.3 and 11.1.0.7 index creation and rebuild finally became consistent with table creation and move when running in <em><strong>noarchivelog</strong></em> mode. The book was right &#8211; it was, after all, talking about Exadata which means it&#8217;s implicitly talking about 11g and doesn&#8217;t really have to qualify the comment with references to earlier versions.</p>
<p>There&#8217;s a secondary moral to this story: instead of saying: &#8220;You&#8217;re wrong&#8221;, you might look a little wiser if you start with &#8220;Are you sure about that?&#8221; or even &#8220;Which version are you thinking of?&#8221;</p>
<p>There&#8217;s another corollary, of course &#8211; if you decide to test out the time and impact of rebuilding a very large index by using a backup copy of your production system, make sure that you are running in <em><strong>archivelog</strong> </em>mode or you won&#8217;t be doing a test that is anything like valid for the production system (assuming your production systems are running in archivelog mode, of course).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8961/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8961/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8961/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8961&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/05/28/ch-ch-ch-ch-changes/feed/</wfw:commentRss>
		<slash:comments>3</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>Subquery Factoring</title>
		<link>http://jonathanlewis.wordpress.com/2012/05/24/subquery-factoring-7/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/05/24/subquery-factoring-7/#comments</comments>
		<pubDate>Thu, 24 May 2012 18:37:26 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Execution plans]]></category>
		<category><![CDATA[Hints]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Subquery Factoring]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8937</guid>
		<description><![CDATA[I have a small collection of postings where I&#8217;ve described anomalies or limitations in subquery factoring (the &#8220;with subquery&#8221;, or Common Table Expression (CTE) to give it the official ANSI name). Here&#8217;s another example of Oracle&#8217;s code not behaving consistently. You may recognise the basic query from yesterday&#8217;s example of logical tuning &#8211; so I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8937&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have a <a href="http://jonathanlewis.wordpress.com/category/oracle/tuning/subquery-factoring/"><strong><em>small collection of postings </em></strong></a>where I&#8217;ve described anomalies or limitations in subquery factoring (the <em>&#8220;with subquery&#8221;</em>, or<em> Common Table Expression</em> (CTE) to give it the official ANSI name). Here&#8217;s another example of Oracle&#8217;s code not behaving consistently. You may recognise the basic query from <a href="http://jonathanlewis.wordpress.com/2012/05/23/logical-tuning"><em><strong>yesterday&#8217;s example of logical tuning</strong></em></a> &#8211; so I won&#8217;t reprint the code to generate the data sets. This examples in this note were created on 11.2.0.2 &#8211; we start with a simple query and its execution plan:</p>
<p><pre class="brush: plain; gutter: false;">
select
	*
from
	t2
where
	not exists (
		select	null
		from 	t3
		where	n3a = n2a
		and	n3b = n2b
		and	id3 = id2
	)
and	not exists (
		select	null
		from 	t3
		where	n3a = n2a
		and	n3b = n2b
		and	id3 = id2 + 1000
	)
;

-------------------------------------------------------------
| Id  | Operation           | Name  | Rows  | Bytes | Cost  |
-------------------------------------------------------------
|   0 | SELECT STATEMENT    |       |    50 |  7200 |    16 |
|   1 |  NESTED LOOPS ANTI  |       |    50 |  7200 |    16 |
|   2 |   NESTED LOOPS ANTI |       |  4999 |   644K|    16 |
|   3 |    TABLE ACCESS FULL| T2    |  5000 |   585K|    16 |
|*  4 |    INDEX UNIQUE SCAN| T3_PK |     1 |    12 |       |
|*  5 |   INDEX UNIQUE SCAN | T3_PK |  5000 | 60000 |       |
-------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   4 - access(&quot;N3A&quot;=&quot;N2A&quot; AND &quot;N3B&quot;=&quot;N2B&quot; AND &quot;ID3&quot;=&quot;ID2&quot;+1000)
   5 - access(&quot;N3A&quot;=&quot;N2A&quot; AND &quot;N3B&quot;=&quot;N2B&quot; AND &quot;ID3&quot;=&quot;ID2&quot;)

</pre></p>
<p>Now what happens if I take this piece of SQL (which is really the core of a much more complex query), put it into a CTE, and reference it later ? In one of the queries in the client&#8217;s application I wanted to materialize a piece of code like this because the result set was used multiple times in the body of the query. You&#8217;ll notice that I got two <em><strong>anti-joins</strong></em> when my test case ran as a &#8220;naked&#8221; SQL statement, but look what happens when I try to use the CTE mechanism in the simplest possible way:</p>
<p><pre class="brush: plain; gutter: false;">
with	cte as (
select
	/*+ materialize */
	*
from
	t2
where
	not exists (
		select
			null
		from 	t3
		where	n3a = n2a
		and	n3b = n2b
		and	id3 = id2
	)
and	not exists (
		select
			null
		from 	t3
		where	n3a = n2a
		and	n3b = n2b
		and	id3 = id2 + 1000
	)
)
select
	*
from
	cte
;

------------------------------------------------------------------------------------------
| Id  | Operation                  | Name                        | Rows  | Bytes | Cost  |
------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT           |                             |  5000 |   468K|  5029 |
|   1 |  TEMP TABLE TRANSFORMATION |                             |       |       |       |
|   2 |   LOAD AS SELECT           | SYS_TEMP_0FD9D6641_40101879 |       |       |       |
|*  3 |    FILTER                  |                             |       |       |       |
|   4 |     TABLE ACCESS FULL      | T2                          |  5000 |   585K|    15 |
|*  5 |     INDEX UNIQUE SCAN      | T3_PK                       |     1 |    12 |     1 |
|*  6 |     INDEX UNIQUE SCAN      | T3_PK                       |     1 |    12 |     1 |
|   7 |   VIEW                     |                             |  5000 |   468K|    14 |
|   8 |    TABLE ACCESS FULL       | SYS_TEMP_0FD9D6641_40101879 |  5000 |   585K|    14 |
------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   3 - filter( NOT EXISTS (SELECT 0 FROM &quot;T3&quot; &quot;T3&quot; WHERE &quot;ID3&quot;=:B1 AND &quot;N3B&quot;=:B2
              AND &quot;N3A&quot;=:B3) AND  NOT EXISTS (SELECT 0 FROM &quot;T3&quot; &quot;T3&quot; WHERE &quot;ID3&quot;=:B4+1000 AND
              &quot;N3B&quot;=:B5 AND &quot;N3A&quot;=:B6))
   5 - access(&quot;N3A&quot;=:B1 AND &quot;N3B&quot;=:B2 AND &quot;ID3&quot;=:B3)
   6 - access(&quot;N3A&quot;=:B1 AND &quot;N3B&quot;=:B2 AND &quot;ID3&quot;=:B3+1000)

</pre></p>
<p>When I try to materialize the view Oracle reverts to a pair of filter subqueries. If I take away the <em><strong>/*+ materialize */</strong></em> hint the CTE goes inline and the query optimizes with <em><strong>anti-joins</strong></em> &#8211; just as it did in the original form &#8211; so the behaviour isn&#8217;t as inconsistent as some of the earlier cases I&#8217;ve documented. I can get the behaviour I want by adding <em><strong>/*+ unnest */</strong></em> hints to the two subqueries so the problem isn&#8217;t a show-stopper, but it&#8217;s just a little irritating to have to do this.</p>
<p>Here&#8217;s what I found in the 10053 trace file with the attempt to materialize:</p>
<p><pre class="brush: plain; gutter: false;">
SU:   Checking validity of unnesting subquery SEL$2 (#0)
SU:     SU bypassed: invalidated.
SU:   Validity checks failed.
SU:   Checking validity of unnesting subquery SEL$3 (#0)
SU:     SU bypassed: invalidated.
SU:   Validity checks failed.
</pre></p>
<p>That&#8217;s just a little strange, considering that the equivalent section of the trace for the version where the CTE goes inline reads as folllows:</p>
<p><pre class="brush: plain; gutter: false;">
SU:   Checking validity of unnesting subquery SEL$2 (#3)
SU:   Passed validity checks.
SU:   Unnesting subquery query block SEL$2 (#3)SU: Transform ALL/NOTEXISTS subquery into a regular antijoin.
SU:   Checking validity of unnesting subquery SEL$3 (#2)
SU:   Passed validity checks.
SU:   Unnesting subquery query block SEL$3 (#2)SU: Transform ALL/NOTEXISTS subquery into a regular antijoin.
</pre></p>
<p>Thank goodness we can still hint &#8211; and then generate SQL Baselines.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8937/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8937/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8937/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8937&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/05/24/subquery-factoring-7/feed/</wfw:commentRss>
		<slash:comments>6</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>Logical tuning</title>
		<link>http://jonathanlewis.wordpress.com/2012/05/23/logical-tuning/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/05/23/logical-tuning/#comments</comments>
		<pubDate>Wed, 23 May 2012 18:22:12 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Hints]]></category>
		<category><![CDATA[Ignoring Hints]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8927</guid>
		<description><![CDATA[Here&#8217;s a model of a problem I solved quite recently at a client site. The actual query involved was much more complex and the volume of data much larger, but this tiny, two table, example was enough to demonstrate the key principle. (Originally I thought I&#8217;d have to use three tables to model the problem, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8927&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a model of a problem I solved quite recently at a client site. The actual query involved was much more complex and the volume of data much larger, but this tiny, two table, example was enough to demonstrate the key principle. (Originally I thought I&#8217;d have to use three tables to model the problem, which is why you my be puzzled by my numerically odd choice of table names). I ran this example on 11.2.0.2 &#8211; the client version:</p>
<p><pre class="brush: plain; gutter: false;">
create table t2
as
select
	rownum					id2,
	trunc(dbms_random.value(0,1000))	n2a,
	trunc(dbms_random.value(0,1000))	n2b,
	lpad(rownum,6,'0')			vc2,
	lpad('x',100,'x')			padding
from
	all_objects
where
	rownum &lt;= 5000;

alter table t2 add constraint t2_pk primary key(id2, n2a);

create table t3
as
select
	rownum					id3,
	trunc(dbms_random.value(0,1000))	n3a,
	trunc(dbms_random.value(0,1000))	n3b,
	lpad(rownum,6,'0')			vc3,
	lpad('x',100,'x')			padding
from
	all_objects
where
	rownum &lt;= 5000;

alter table t3 add constraint t3_pk primary key(n3a, n3b, id3);

-- now collect stats on the table and execute this query (with autotrace enabled)

select
	*
from
	t2
where
	not exists (
		select	/*+ unnest */
			null
		from 	t3
		where	n3a = n2a
		and	n3b = n2b
		and	(id3 = id2 or id3 = id2 + 1000)
	)
;

select * from table(dbms_xplan.display);

</pre></p>
<p>You&#8217;ll note that I&#8217;ve included the <em><strong>/*+ unnest */</strong></em> hint in the subquery because I want Oracle to run this as a <em><strong>hash anti-join</strong></em>; and it would appear to be legal (and simple) to do this given the various <em><strong>not null</strong></em> contraints and primary key information. In fact the plan uses a <em><strong>filter subquery</strong></em>:</p>
<p><pre class="brush: plain; gutter: false;">
------------------------------------------------------------
| Id  | Operation          | Name  | Rows  | Bytes | Cost  |
------------------------------------------------------------
|   0 | SELECT STATEMENT   |       |  5000 |   585K|  5015 |
|*  1 |  FILTER            |       |       |       |       |
|   2 |   TABLE ACCESS FULL| T2    |  5000 |   585K|    15 |
|*  3 |   INDEX RANGE SCAN | T3_PK |     1 |    12 |     2 |
------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter( NOT EXISTS (SELECT /*+ UNNEST */ 0 FROM &quot;T3&quot; &quot;T3&quot; WHERE
              &quot;N3B&quot;=:B1 AND &quot;N3A&quot;=:B2 AND (&quot;ID3&quot;=:B3 OR &quot;ID3&quot;=:B4+1000)))
   3 - access(&quot;N3A&quot;=:B1 AND &quot;N3B&quot;=:B2)
       filter(&quot;ID3&quot;=:B1 OR &quot;ID3&quot;=:B2+1000)

</pre></p>
<p>I suspect that the optimizer code bypasses the <em><strong>anti-join</strong></em> because of the (carefully bracketed) disjunct (OR) predicate. On the client site this resulted in the subquery being executed 9 million times, reducing an intermediate data set from 9M rows to 2M rows at a cost of 27 million buffer visits and about 60 CPU seconds. Fortunately I was able to dredge up a little bit of propositional calculus and quote the following equivalence:</p>
<p><pre class="brush: plain; gutter: false;">
        not( A or B )  (not A and not B)
</pre></p>
<p>Equally fortunately I didn&#8217;t have to worry about three-valued logic (all relevant columns were declared not null), so I was able to rewrite the query in the form:</p>
<p><pre class="brush: plain; gutter: false;">
select
	*
from
	t2
where
	not exists (
		select	null
		from 	t3
		where	n3a = n2a
		and	n3b = n2b
		and	id3 = id2
	)
and	not exists (
		select	null
		from 	t3
		where	n3a = n2a
		and	n3b = n2b
		and	id3 = id2 + 1000
	)
;

</pre></p>
<p>With this code Oracle did two <em><strong>unnests</strong> </em>and converted to <em><strong>hash anti-joins</strong></em>in both cases (at least, that&#8217;s what happened on the client site &#8211; my small sample switched to <em><strong>nested loop anti-joins</strong></em>):</p>
<p><pre class="brush: plain; gutter: false;">
-------------------------------------------------------------
| Id  | Operation           | Name  | Rows  | Bytes | Cost  |
-------------------------------------------------------------
|   0 | SELECT STATEMENT    |       |    50 |  7200 |    15 |
|   1 |  NESTED LOOPS ANTI  |       |    50 |  7200 |    15 |
|   2 |   NESTED LOOPS ANTI |       |  4999 |   644K|    15 |
|   3 |    TABLE ACCESS FULL| T2    |  5000 |   585K|    15 |
|*  4 |    INDEX UNIQUE SCAN| T3_PK |     1 |    12 |       |
|*  5 |   INDEX UNIQUE SCAN | T3_PK |  5000 | 60000 |       |
-------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   4 - access(&quot;N3A&quot;=&quot;N2A&quot; AND &quot;N3B&quot;=&quot;N2B&quot; AND &quot;ID3&quot;=&quot;ID2&quot;+1000)
   5 - access(&quot;N3A&quot;=&quot;N2A&quot; AND &quot;N3B&quot;=&quot;N2B&quot; AND &quot;ID3&quot;=&quot;ID2&quot;)

</pre></p>
<p>The change to <em><strong>hash anti-joins</strong></em> was a huge benefit (the <em><strong>nested loop anti-join</strong></em> would have improved things for the client to a degree, but there&#8217;s not really an enormouse difference in some cases between a <em><strong>filter subquery</strong></em> and an equivalent <em><strong>nested loop anti/semi-join</strong></em>). In this case the query run time dropped from 95 seconds to 27 seconds &#8211; all of it CPU time.</p>
<p><strong>Update:</strong> a check of the 10053 trace file for 10.2.0.3 shows the following:</p>
<p><pre class="brush: plain; gutter: false;">
SU:   Checking validity of unnesting subquery SEL$2 (#2)
SU:     SU bypassed: Invalid correlated predicates.
SU:   Validity checks failed.
</pre></p>
<p>On the other hand, it is possible to get unnesting and a hash anti-join with the predicate: <em><strong>id3 between id2 and id2 + 1000</strong></em>. (But see <a href="http://jonathanlewis.wordpress.com/2012/05/23/logical-tuning/#comment-46666"><em>comment 6</em></a> and its reply)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8927/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8927/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8927/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8927/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8927/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8927/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8927/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8927/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8927/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8927/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8927/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8927/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8927/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8927/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8927&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/05/23/logical-tuning/feed/</wfw:commentRss>
		<slash:comments>13</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>Index Sizing</title>
		<link>http://jonathanlewis.wordpress.com/2012/05/17/index-sizing/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/05/17/index-sizing/#comments</comments>
		<pubDate>Thu, 17 May 2012 08:53:16 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Indexing]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8899</guid>
		<description><![CDATA[I was in a discussion recently about how to estimate the size of a bitmap index before you build it, and why it&#8217;s much harder to do this for bitmap indexes than it is for B-tree indexes. Here&#8217;s what I wrote in &#8220;Practical Oracle 8i&#8221;: An interesting feature of bitmap indexes is that it is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8899&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was in a discussion recently about how to estimate the size of a bitmap index before you build it, and why it&#8217;s much harder to do this for bitmap indexes than it is for B-tree indexes. Here&#8217;s what I wrote in &#8220;Practical Oracle 8i&#8221;:</p>
<p style="padding-left:30px;"><em>An interesting feature of bitmap indexes is that it is rather hard to predict how large the index segment will be. The size of a b-tree index is based very closely on the number of rows and the typical size of the entries in the index column.  The size of a bitmap index is dictated by a fairly small number of bit-strings which may have been compressed to some degree depending upon the number of consecutive 1’s and 0’s.   To pick an extreme example, imagine a table of one million rows that has one column that may contain one of eight values ‘A’ to ‘H’ say, which has been generated in one of of the two following extreme patterns: </em></p>
<ul>
<li>
<div style="padding-left:30px;"><em>All the rows for a given value appear together, so scanning down the table we get 125,000 rows with ‘A’ followed by 125,000 rows of ‘B’ and so on. </em></div>
</li>
<li>
<div style="padding-left:30px;"><em>The rows cycle through the values in turn, so scanning down the table we get ‘A’,’B’. . . ‘H’ repeated 125,000 times.  </em></div>
</li>
</ul>
<p style="padding-left:30px;"><em>What will the bitmap indexes look like in the two cases?  </em></p>
<p style="padding-left:30px;"><em>For the first example, the basic map for the ‘A’ value will be 125,000 one-bits, followed by 875,000 zero bits – which will be trimmed off.  Splitting the 125,000 bits into bytes and adding the necessary overhead of about 12% we get an entry for the ‘A’ rows of 18K.  A similar argument applies for each of the values ‘B’ to ‘H’, so we get a total index size of around 8 x 18K &#8211; giving 156K.  </em></p>
<p style="padding-left:30px;"><em>For the second example, the basic map for the ‘A’ value will be a one followed by 7 zeros, repeated 125,000 times.  There is no chance of compression here, so the ‘A’ entry will start at 125,000 bytes.  Adding the overhead this goes up to 140K, and repeating the argument for the values ‘B’ to ‘H’ we get a total index of 1.12 MB.  </em></p>
<p style="padding-left:30px;"><em>This wild variation in size looks like a threat, but to put this into perspective, a standard B-tree index on this column would run to about 12 Mb irrespective of the pattern of the data.  It would probably take about ten times as long to build as well. </em></p>
<p>I wrote up a test case to recreate this model some time ago, so here it is with the results from an instance of 11.1.0.7:</p>
<p><pre class="brush: plain; gutter: false;">
create table t1
as
with generator as (
	select	--+ materialize
		rownum id 
	from dual 
	connect by 
		level &lt;= 10000
)
select
	chr(65 + mod(rownum-1,8))		bit_scattered,
	chr(65+trunc((rownum-1)/125000))	bit_clustered
from
	generator	v1,
	generator	v2
where
	rownum &lt;= 1e6
;

create bitmap index t1_b1_scattered on t1(bit_scattered);
create bitmap index t1_b1_clustered on t1(bit_clustered);

select
	index_name, leaf_blocks, 8 * leaf_blocks KB
from
	user_indexes
where
	table_name = 'T1'
;

set doc off
doc

Results from 11.1.0.7
---------------------

INDEX_NAME           LEAF_BLOCKS         KB
-------------------- ----------- ----------
T1_B1_SCATTERED              164       1312
T1_B1_CLUSTERED               24        192

2 rows selected.
#
</pre></p>
<p>So, no big change there, then.<br />
If you modify the code to create B-tree indexes you&#8217;ll find they are 14MB each if you don&#8217;t use compression, 12MB if you do.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8899/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8899/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8899/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8899&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/05/17/index-sizing/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>Exadata</title>
		<link>http://jonathanlewis.wordpress.com/2012/05/11/exadata-2/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/05/11/exadata-2/#comments</comments>
		<pubDate>Fri, 11 May 2012 14:12:16 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Advertisements]]></category>
		<category><![CDATA[Exadata]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8886</guid>
		<description><![CDATA[Enkitec have just announced the call for papers for their E4 conference to be held in Irving, Texas this August. (See this link for the announcement.) I&#8217;ll be there &#8230; playing the devil&#8217;s advocate.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8886&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Enkitec have just announced the <a href="http://www.enkitec.com/e4/call-for-papers/"><em><strong>call for papers</strong></em></a> for their <a href="http://www.enkitec.com/e4/"><em><strong>E4 conference</strong></em></a> to be held in Irving, Texas this August. (See <a href="http://www.prweb.com/releases/2012/5/prweb9495493.htm"><em><strong>this link</strong></em></a> for the announcement.)</p>
<p>I&#8217;ll be there &#8230; playing the devil&#8217;s advocate.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8886/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8886/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8886/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8886&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/05/11/exadata-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>Web Cams</title>
		<link>http://jonathanlewis.wordpress.com/2012/05/01/web-cams/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/05/01/web-cams/#comments</comments>
		<pubDate>Tue, 01 May 2012 17:04:24 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8834</guid>
		<description><![CDATA[A little something to revive flagging spirits at the end of the day: Red-tailed Hawk nest Great Blue Heron nest / alternative view It&#8217;s wonderful to &#8220;be&#8221; this close to the nests and see such detail (ymmv, depending on time of day).<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8834&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A little something to revive flagging spirits at the end of the day:</p>
<p><a href="http://www.allaboutbirds.org/page.aspx?pid=2422" target="_blank"><em><strong>Red-tailed Hawk nest</strong></em></a></p>
<p><em><strong><a href="http://www.allaboutbirds.org/page.aspx?pid=2433" target="_blank">Great Blue Heron nest</a> / <a href="http://www.allaboutbirds.org/page.aspx?pid=2437" target="_blank">alternative view</a></strong></em></p>
<p>It&#8217;s wonderful to &#8220;be&#8221; this close to the nests and see such detail (ymmv, depending on time of day).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8834/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8834/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8834/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8834/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8834/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8834/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8834/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8834/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8834/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8834/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8834/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8834/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8834/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8834/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8834&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/05/01/web-cams/feed/</wfw:commentRss>
		<slash:comments>3</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>BT/Yahoo</title>
		<link>http://jonathanlewis.wordpress.com/2012/05/01/btyahoo/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/05/01/btyahoo/#comments</comments>
		<pubDate>Tue, 01 May 2012 08:00:41 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8830</guid>
		<description><![CDATA[If anyone is expecting email from me any time in the near future, you may have to hold your breath. In a staggering feat of customer relations BT (British Telecomms), or Yahoo acting on their behalf, has managed to introduce random blocks to any email I send out. At present I have something like a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8830&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If anyone is expecting email from me any time in the near future, you may have to hold your breath.</p>
<p>In a staggering feat of customer relations BT (British Telecomms), or Yahoo acting on their behalf, has managed to introduce random blocks to any email I send out. At present I have something like a 30% chance of email being blocked by their smtp servers with reports like the following:</p>
<p style="padding-left:30px;"><em>An unknown error has occurred. Subject &#8216;Re: </em>{deleted}<em>&#8216;, Account: &#8216;</em>{deleted}<em>&#8216;, Server: &#8216;mail.btinternet.com&#8217;, Protocol: SMTP, Server Response: &#8217;554 Transaction failed : Cannot send message due to possible abuse; please visit <strong>http://postmaster.yahoo.com/abuse_smtp.html</strong> for more information&#8217;, Port: </em>{deleted}<em>, Secure(SSL): </em>{deleted}<em>, Server Error: 554, Error Number: 0x800CCC6F</em></p>
<p>Take a look at the URL supplied in the response &#8211; I&#8217;ve highlighted it to make it easy to spot &#8211; and then try going to that URL.  (Page doesn&#8217;t exist &#8211; excellent service, isn&#8217;t it?)</p>
<p>Sometimes I can get my reply through if I delete any of the original text, sometimes I can get my reply through if I create a whole new message (rather than hitting reply) and cut just my text into the new message. Sometimes I can hit reply and get a reply through if it contains nothing but the comment (with no signature, and nothing from the incoming post):</p>
<p style="padding-left:30px;"><em>British Telecomm is blocking virtually every email I try to send to you as &#8220;possible abuse&#8221;.</em><br />
<em>I can&#8217;t figure out why, so it may be some time before I get a proper reply through.</em></p>
<p>I tried calling customer support and was told that the problem  was obviously my configuration and not their mail servers; but they could email me the URL of the BT broadband help page so that I could find out how to set up mail program properly; or I could let the call centre employee log on to my machine over the internet; or I could pay them to get a member of the support staff  to help.</p>
<p>Of course there was no answer to the question:  <em>&#8220;so what have BT/Yahoo changed on their mail servers in the last few days?&#8221;</em> and there was no answer to the question: <em>&#8220;why have several other people suddenly hit the same problem at the same time if it&#8217;s my configuration?&#8221;</em>.</p>
<p>So, BT, get your act together &#8211; send an email to your customers explaining why your email servers might choose to block apparently random email as &#8220;possible abuse&#8221;; and brief your call centre staff to recognise the description of the problem so they don&#8217;t try the standard brush-off</p>
<p>I hear that using twitter, facebook, blogs etc. to make a fuss about  poor quality service is more effective nowadays than phoning call centres in distant countries &#8211; so I thought I&#8217;d give it a go. I know I&#8217;m not the only one in the UK facing this problem at the moment, so I&#8217;m curious to see how many more people I can get complaining about it.</p>
<p><strong>Footnote:</strong> I have a yahoo mail account via  BT &#8211; and the fact that I could send an email from it &#8220;proved&#8221; to the call centre person that it wasn&#8217;t BT&#8217;s problem. But it doesn&#8217;t, and I don&#8217;t want to use a service that floods half my screen with moving adverts all the time.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8830/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8830/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8830/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8830/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8830/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8830/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8830/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8830/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8830/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8830/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8830/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8830/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8830/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8830/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8830&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/05/01/btyahoo/feed/</wfw:commentRss>
		<slash:comments>16</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>Clustered Indexes</title>
		<link>http://jonathanlewis.wordpress.com/2012/04/30/clustered-indexes/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/04/30/clustered-indexes/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 14:15:56 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8826</guid>
		<description><![CDATA[&#8230; which, for those in the know, means something to do with SQL Server. (The closest Oracle equivalent is index-organized tables, the closest sounding Oracle feature is &#8220;index clusters&#8221; but that means something rather different.) Redgate has arranged for an online debate between an Oracle specialist (me) and a SQL Server specialist (Grant Fritchey) to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8826&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8230; which, for those in the know, means something to do with SQL Server. (The closest Oracle equivalent is index-organized tables, the closest sounding Oracle feature is <em>&#8220;index clusters&#8221;</em> but that means something rather different.)</p>
<p>Redgate has arranged for an online debate between an Oracle specialist (me) and a SQL Server specialist (Grant Fritchey) to talk about the strengths and weaknesses of the two mechanisms, discuss why Oracle users seem to be biased towards one implementation and SQL Server users towards the other, and then see where the conversation takes us. This will be followed by a Q&amp;A session.</p>
<p>If this sounds interesting &#8211; and I think it&#8217;s a great idea, you can learn an awful lot more from a discussion than you can by listening to monologue &#8211; you need to sign up early. The event will be held on 7th June at 8:00 am (which is 16:00 BST as far as I&#8217;m concerned).</p>
<p>Further details and registration <a href="http://www.red-gate.com/products/oracle-development/deployment-suite-for-oracle/webinars/webinar-oracle-heaped-tables-sql-clustered-indexes"><em><strong>at this URL</strong></em></a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8826/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8826&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/04/30/clustered-indexes/feed/</wfw:commentRss>
		<slash:comments>5</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>SQLTXPLAIN</title>
		<link>http://jonathanlewis.wordpress.com/2012/04/28/sqltxplain/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/04/28/sqltxplain/#comments</comments>
		<pubDate>Sat, 28 Apr 2012 11:53:57 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8821</guid>
		<description><![CDATA[Just in on the Oracle-L list server &#8211; if you want to hear from the author of SQLTXPLAIN (MOS 215187.1) how to install and use the main features, Carlos Sierra is presenting a one hour seminar on May 15th. In his words: If you or someone you know may want to attend, please register following link [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8821&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just in on the Oracle-L list server &#8211; if you want to hear from the author of SQLTXPLAIN (MOS 215187.1) how to install and use the main features, Carlos Sierra is presenting a one hour seminar on May 15th. In his words:</p>
<p style="padding-left:30px;"><em>If you or someone you know may want to attend, please register following link below. Capacity for this 1hr SQLTXPLAIN Webinar on May 15 is limited, so please register early so you can reserve one connection. Feel free to share this link with your customer(s).</em></p>
<p style="padding-left:30px;"><em></em><em><a href="https://oracleaw.webex.com/oracleaw/onstage/g.php?d=590415036&amp;t=a">https://oracleaw.webex.com/oracleaw/onstage/g.php?d=590415036&amp;t=a</a></em></p>
<p style="padding-left:30px;"><em>Event Information: Using SQLTXPLAIN to diagnose SQL statements performing poorly</em></p>
<p>The event is scheduled for 8:00 am in San Francisco, which is 4:00 pm BST (GMT+1) if you&#8217;re in the UK.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8821/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8821/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8821/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8821/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8821/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8821/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8821/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8821/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8821/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8821/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8821/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8821/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8821/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8821/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8821&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/04/28/sqltxplain/feed/</wfw:commentRss>
		<slash:comments>2</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>NVL2()</title>
		<link>http://jonathanlewis.wordpress.com/2012/04/23/nvl2/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/04/23/nvl2/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 17:43:26 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Function based indexes]]></category>
		<category><![CDATA[Indexing]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8811</guid>
		<description><![CDATA[There are many little bits and pieces lurking in the Oracle code set that would be very useful if only you had had time to notice them. Here&#8217;s one that seems to be virtually unknown, yet does a wonderful job of eliminating calls to decode(). The nvl2() function takes three parameters, returning the third if [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8811&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are many little bits and pieces lurking in the Oracle code set that would be very useful if only you had had time to notice them. Here&#8217;s one that seems to be virtually unknown, yet does a wonderful job of eliminating calls to <em><strong>decode()</strong></em>.</p>
<p>The<em><strong> nvl2()</strong></em> function takes three parameters, returning the third if the first is null and returning the second if the first is not null. This is  convenient for all sorts of example where you might otherwise use an expression involving  <em><strong>case</strong> </em>or <em><strong>decode()</strong></em>, but most particularly it&#8217;s a nice little option if you want to create a function-based index that indexes only those rows where a column is null.</p>
<p>Here&#8217;s a code fragment to demonstrate the effect:</p>
<p><pre class="brush: plain; gutter: false;">
select nvl2(1,2,3) from dual;

select nvl2(null,2,3) from dual;

select nvl2(1,null,3) from dual;

select nvl2(null,null,3) from dual;
</pre></p>
<p>And here&#8217;s the resulting output &#8211; conveniently the function call is also the column heading in the output:</p>
<p><pre class="brush: plain; gutter: false;">
NVL2(1,2,3)
-----------
          2

NVL2(NULL,2,3)
--------------
             3

NVL2(1,NULL,3)
--------------

NVL2(NULL,NULL,3)
-----------------
                3

</pre></p>
<p>Note, particularly, from the last two that a non-null input (first parameter) turns into the null second parameter, and the null input turns into the non-null third parameter. To create a function-based index on rows where columnX is null, and be able to access them by index, you need only do the following:</p>
<p><pre class="brush: plain; gutter: false;">
create index t1_f1 on t1(nvl2(columnX,null,1));

select * from t1 where nvl2(columnX,null,1) = 1;
</pre><br />
(Don&#8217;t forget, of course, that you will need to gather stats on the hidden column underpinning the function-based index before you can expect the optimizer to use it in the correct cases.)</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8811/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8811/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8811/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8811/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8811/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8811/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8811/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8811/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8811/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8811/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8811/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8811/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8811/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8811/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#038;blog=491988&#038;post=8811&#038;subd=jonathanlewis&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/04/23/nvl2/feed/</wfw:commentRss>
		<slash:comments>5</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>
