<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kerry Osborne's Oracle Blog</title>
	<atom:link href="http://kerryosborne.oracle-guy.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://kerryosborne.oracle-guy.com</link>
	<description>Just another Oracle blog</description>
	<lastBuildDate>Thu, 12 Apr 2012 04:36:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Free Instant SQL Formatter</title>
		<link>http://kerryosborne.oracle-guy.com/2012/04/free-instant-sql-formatter/</link>
		<comments>http://kerryosborne.oracle-guy.com/2012/04/free-instant-sql-formatter/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 04:36:20 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3800</guid>
		<description><![CDATA[Well apparently you can teach an old dog new tricks. I recently sent the following email to Enkitec&#8217;s internal techie email list: Begin forwarded message: Have you ever tried to decipher a really ugly, unformatted SQL statement that someone gave you or you pulled out of one the database views or an AWR report? Tim [...]]]></description>
			<content:encoded><![CDATA[<p>Well apparently you can teach an old dog new tricks. I recently sent the following email to Enkitec&#8217;s internal techie email list:</p>
<blockquote><p>
Begin forwarded message:</p>
<p>Have you ever tried to decipher a really ugly, unformatted SQL statement that someone gave you or you pulled out of one the database views or an AWR report? Tim Fox turned me on to the SQL formatting capability of SQL Developer a few weeks ago (actually Brian Hill found it first and showed Tim). It is awesome! It&#8217;s a little unintuitive to use though. Here&#8217;s how I use it.</p>
<p>1. start up the SQL Developer (there are versions for Mac OS and Windows by the way)<br />
2. Click File->New and choose the SQL File option<br />
  &#8211; this opens a Query Builder Pane (you don&#8217;t need to connect to a database)<br />
3. Pick any random file to open<br />
4. Paste your nasty 10 page long query into the Query Builder pane replacing the text from your random file<br />
5. Right click on the text in the window (brings up a long menu)<br />
6. Click the Format menu Item (it&#8217;s at the bottom of the menu in version 3.0)</p>
<p>Viola &#8211; nicely formatted SQL text</p>
<p>The latest version of SQL Developer (3.0.x) is actually much better than the previous version by the way.</p>
<p>I haven&#8217;t closed SQL Developer since I found out about this capability!
</p></blockquote>
<p>SQL Developer is a free tool that can be downloaded from Oracle&#8217;s web site here: </p>
<p>http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html</p>
<p>Note version 3.1 is now available but I haven&#8217;t tried it yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2012/04/free-instant-sql-formatter/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Displaying SQL Baseline Plans</title>
		<link>http://kerryosborne.oracle-guy.com/2012/03/displaying-sql-baseline-plans/</link>
		<comments>http://kerryosborne.oracle-guy.com/2012/03/displaying-sql-baseline-plans/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 20:33:21 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Plan Stability]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3844</guid>
		<description><![CDATA[Since I&#8217;m on vacation and not &#8220;really&#8221; working, I thought I might have time to write up a quick blog post. The idea for this one was triggered by one of Maria Colgan&#8217;s presentations at Hotsos last week. Maria was talking about SQL Plan Management and Baselines and somehow got me thinking about the DBMS_XPLAN [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;m on vacation and not &#8220;really&#8221; working, I thought I might have time to write up a quick blog post. The idea for this one was triggered by one of Maria Colgan&#8217;s presentations at Hotsos last week. Maria was talking about SQL Plan Management and Baselines and somehow got me thinking about the DBMS_XPLAN option to display plans for Baselines. This is a pretty neat feature that allows you to the see the plan associated with a Baseline (well sort of).</p>
<p>The 11.2 documentation (Oracle® Database PL/SQL Packages and Types Reference) says this about the DISPLAY_SQL_PLAN_BASELINE function:</p>
<blockquote><p>This procedure uses plan information stored in the plan baseline to explain and display the plans.It is possible that the plan_id stored in the SQL management base may not match with the plan_id of the generated plan. A mismatch between stored plan_id and generated plan_id means that it is a non-reproducible plan. Such a plan is deemed invalid and is bypassed by the optimizer during SQL compilation.</p></blockquote>
<p>But what does that mean? Well in short it means that Baselines don&#8217;t store plans, they store hints that when fed to the optimizer will hopefully cause it to come up with the desired plan. Baselines also store a plan_hash_value so it&#8217;s possible to tell whether the hints worked or not. Baselines do not actually store all the steps of a plan. So if that&#8217;s the case, then it&#8217;s obviously not possible for the display_sql_plan_baseline function to show the plan if the optimizer can&#8217;t reproduce it for some reason. When the doc&#8217;s say &#8220;it is possible that the plan_id stored in the SQL management base may not match with the plan_id of the generated plan&#8221;, that&#8217;s what they are talking about. I decided to create a test case to see what happens when the generated plan can&#8217;t match the original. Here&#8217;s the basic idea:</p>
<ol>
<li>run a statement that uses an index and check the plan</li>
<li>create a Baseline on the statement using the index (using my <a href="http://kerryosborne.oracle-guy.com/scripts/create_baseline.sql">create_baseline.sql</a> script)</li>
<li>check the hints stored with the baseline (using my <a href="http://kerryosborne.oracle-guy.com/scripts/baseline_hints.sql">baselines_hints.sql</a> script)</li>
<li>run the statement again and check the real plan to see that the Baseline was used</li>
<li>use the display_sql_plan_baseline function to show the Baseline plan</li>
<li>make the index invisible (thus rendering the Baseline plan non-reproducible)</li>
<li>execute the statement again and check the real plan</li>
<li>use the display_sql_plan_baseline function to show the Baseline plan</li>
</ol>
<p>So here&#8217;s the test:</p>
<p><span id="more-3844"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3844code2'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38442"><td class="code" id="p3844code2"><pre class="none" style="font-family:monospace;">&nbsp;
SYS@dbm1&gt; @avgskewi
&nbsp;
AVG(PK_COL)
-----------
&nbsp;
&nbsp;
Elapsed: 00:00:00.02
SYS@dbm1&gt; select * from table(dbms_xplan.display_cursor(null,null,'LAST'));
&nbsp;
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  84q0zxfzn5u6s, child number 0
-------------------------------------
select avg(pk_col) from kso.skew where col1 = 136133
&nbsp;
Plan hash value: 3723858078
&nbsp;
------------------------------------------------------------------------------------------
| Id  | Operation                    | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |           |       |       |    33 (100)|          |
|   1 |  SORT AGGREGATE              |           |     1 |    11 |            |          |
|   2 |   TABLE ACCESS BY INDEX ROWID| SKEW      |    32 |   352 |    33   (0)| 00:00:01 |
|*  3 |    INDEX RANGE SCAN          | SKEW_COL1 |    33 |       |     3   (0)| 00:00:01 |
------------------------------------------------------------------------------------------
&nbsp;
Predicate Information (identified by operation id):
---------------------------------------------------
&nbsp;
   3 - access(&quot;COL1&quot;=136133)
&nbsp;
&nbsp;
20 rows selected.
&nbsp;
Elapsed: 00:00:00.03
SYS@dbm1&gt;
SYS@dbm1&gt; -- Create the Baseline
SYS@dbm1&gt;
SYS@dbm1&gt; @create_baseline
Enter value for sql_id: 7s0b9ygcrj77u
Enter value for plan_hash_value: 3723858078
Enter value for fixed (NO): 
Enter value for enabled (YES): 
Enter value for plan_name (ID_sqlid_planhashvalue): 
&nbsp;
Baseline SQLID_7S0B9YGCRJ77U_3723858078 created.
&nbsp;
Elapsed: 00:00:00.08
SYS@dbm1&gt;
SYS@dbm1&gt; -- Check Baseline Hints
SYS@dbm1&gt;
SYS@dbm1&gt; @baseline_hints
Enter value for baseline_plan_name: SQLID_7S0B9YGCRJ77U_3723858078
&nbsp;
OUTLINE_HINTS
------------------------------------------------------------------------------------------------------------------------------------------------------
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.2.0.3')
DB_VERSION('11.2.0.3')
ALL_ROWS
OUTLINE_LEAF(@&quot;SEL$1&quot;)
INDEX_RS_ASC(@&quot;SEL$1&quot; &quot;SKEW&quot;@&quot;SEL$1&quot; (&quot;SKEW&quot;.&quot;COL1&quot;))
&nbsp;
6 rows selected.
&nbsp;
Elapsed: 00:00:00.04
SYS@dbm1&gt; @avgskewi
&nbsp;
AVG(PK_COL)
-----------
&nbsp;
&nbsp;
1 row selected.
&nbsp;
Elapsed: 00:00:00.01
SYS@dbm1&gt; /
&nbsp;
AVG(PK_COL)
-----------
&nbsp;
&nbsp;
1 row selected.
&nbsp;
Elapsed: 00:00:00.01
SYS@dbm1&gt;
SYS@dbm1&gt; -- Check to make sure statement is using the Baseline
SYS@dbm1&gt;
SYS@dbm1&gt; select * from table(dbms_xplan.display_cursor(null,null,'LAST'));
&nbsp;
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  7s0b9ygcrj77u, child number 0
-------------------------------------
select avg(pk_col) from kso.skew where col1 = 23489
&nbsp;
Plan hash value: 3723858078
&nbsp;
-----------------------------------------------------------
| Id  | Operation                    | Name      | E-Rows |
-----------------------------------------------------------
|   0 | SELECT STATEMENT             |           |        |
|   1 |  SORT AGGREGATE              |           |      1 |
|   2 |   TABLE ACCESS BY INDEX ROWID| SKEW      |     35 |
|*  3 |    INDEX RANGE SCAN          | SKEW_COL1 |     37 |
-----------------------------------------------------------
&nbsp;
Predicate Information (identified by operation id):
---------------------------------------------------
&nbsp;
   3 - access(&quot;COL1&quot;=23489)
&nbsp;
Note
-----
   - SQL plan baseline SQLID_7S0B9YGCRJ77U_3723858078 used for this statement
&nbsp;
27 rows selected.
&nbsp;
Elapsed: 00:00:00.05
SYS@dbm1&gt;
SYS@dbm1&gt; -- Use display_sql_plan_baseline to see Baseline Plan
SYS@dbm1&gt;
SYS@dbm1&gt; select * from table(dbms_xplan.display_sql_plan_baseline('&amp;sql_handle','&amp;plan_name','typical'));
Enter value for sql_handle: SQL_1e2d7159fc8f7496
Enter value for plan_name: SQLID_7S0B9YGCRJ77U_3723858078
&nbsp;
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
&nbsp;
--------------------------------------------------------------------------------
SQL handle: SQL_1e2d7159fc8f7496
SQL text: select avg(pk_col) from kso.skew where col1 = 23489
--------------------------------------------------------------------------------
&nbsp;
--------------------------------------------------------------------------------
Plan name: SQLID_7S0B9YGCRJ77U_3723858078         Plan id: 1416105523
Enabled: YES     Fixed: NO      Accepted: YES     Origin: MANUAL-LOAD
--------------------------------------------------------------------------------
&nbsp;
Plan hash value: 3723858078
&nbsp;
------------------------------------------------------------------------------------------
| Id  | Operation                    | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |           |     1 |    11 |    36   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE              |           |     1 |    11 |            |          |
|   2 |   TABLE ACCESS BY INDEX ROWID| SKEW      |    35 |   385 |    36   (0)| 00:00:01 |
|*  3 |    INDEX RANGE SCAN          | SKEW_COL1 |    37 |       |     3   (0)| 00:00:01 |
------------------------------------------------------------------------------------------
&nbsp;
Predicate Information (identified by operation id):
---------------------------------------------------
&nbsp;
   3 - access(&quot;COL1&quot;=23489)
&nbsp;
26 rows selected.
&nbsp;
Elapsed: 00:00:00.05
SYS@dbm1&gt;
SYS@dbm1&gt; -- Hide the index and rerun the statement
SYS@dbm1&gt;
SYS@dbm1&gt; alter index kso.skew_col1 invisible;
&nbsp;
Index altered.
&nbsp;
Elapsed: 00:00:00.01
SYS@dbm1&gt; @avgskewi
&nbsp;
AVG(PK_COL)
-----------
&nbsp;
&nbsp;
1 row selected.
&nbsp;
Elapsed: 00:00:01.14
SYS@dbm1&gt; /
&nbsp;
AVG(PK_COL)
-----------
&nbsp;
&nbsp;
1 row selected.
&nbsp;
Elapsed: 00:00:01.12
SYS@dbm1&gt;
SYS@dbm1&gt; -- Check the actual plan and see that the Baseline is no longer used
SYS@dbm1&gt;
SYS@dbm1&gt; select * from table(dbms_xplan.display_cursor(null,null,'LAST'));
&nbsp;
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  7s0b9ygcrj77u, child number 0
-------------------------------------
select avg(pk_col) from kso.skew where col1 = 23489
&nbsp;
Plan hash value: 568322376
&nbsp;
----------------------------------------------------
| Id  | Operation                  | Name | E-Rows |
----------------------------------------------------
|   0 | SELECT STATEMENT           |      |        |
|   1 |  SORT AGGREGATE            |      |      1 |
|*  2 |   TABLE ACCESS STORAGE FULL| SKEW |     35 |
----------------------------------------------------
&nbsp;
Predicate Information (identified by operation id):
---------------------------------------------------
&nbsp;
   2 - storage(&quot;COL1&quot;=23489)
       filter(&quot;COL1&quot;=23489)
&nbsp;
&nbsp;
20 rows selected.
&nbsp;
Elapsed: 00:00:00.02
SYS@dbm1&gt;
SYS@dbm1&gt; -- Use display_sql_plan_baseline to see Baseline Plan now
SYS@dbm1&gt;
SYS@dbm1&gt; select * from table(dbms_xplan.display_sql_plan_baseline('&amp;sql_handle','&amp;plan_name','typical'));
Enter value for sql_handle: SQL_1e2d7159fc8f7496
Enter value for plan_name: SQLID_7S0B9YGCRJ77U_3723858078
&nbsp;
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
&nbsp;
--------------------------------------------------------------------------------
SQL handle: SQL_1e2d7159fc8f7496
SQL text: select avg(pk_col) from kso.skew where col1 = 23489
--------------------------------------------------------------------------------
&nbsp;
--------------------------------------------------------------------------------
Plan name: SQLID_7S0B9YGCRJ77U_3723858078         Plan id: 1416105523
Enabled: YES     Fixed: NO      Accepted: YES     Origin: MANUAL-LOAD
--------------------------------------------------------------------------------
&nbsp;
Plan hash value: 568322376
&nbsp;
-----------------------------------------------------------------------------------
| Id  | Operation                  | Name | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT           |      |     1 |    11 | 44513   (2)| 00:00:02 |
|   1 |  SORT AGGREGATE            |      |     1 |    11 |            |          |
|*  2 |   TABLE ACCESS STORAGE FULL| SKEW |    35 |   385 | 44513   (2)| 00:00:02 |
-----------------------------------------------------------------------------------
&nbsp;
Predicate Information (identified by operation id):
---------------------------------------------------
&nbsp;
   2 - storage(&quot;COL1&quot;=23489)
       filter(&quot;COL1&quot;=23489)
&nbsp;
26 rows selected.
&nbsp;
Elapsed: 00:00:00.04</pre></td></tr></table></div>

<p>|<br />
So in the last step you can see that the display_sql_plan_baseline function does not actually show the plan that was associated with the baseline. It can&#8217;t because the plan is not stored. So the optimizer must attempt to reproduce the plan with the hints and if the plan is not reproducible, it spits out some other plan. Note that the plan_id in the output still matches the desired plan even though the optimizer was unable to reproduce this plan.</p>
<p>Note: After I wrote this up I realized that Coskan Gundogar had already blogged about it <a href="http://coskan.wordpress.com/2011/08/13/dbms_xplan-display_sql_plan_baseline-can-also-lie/">here</a> (pretty thoroughly I might add). So please see his post as well. By the way, I do agree with his point that when a plan is not reproducible the display_sql_plan_baseline function should probably just throw an error. </p>
]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2012/03/displaying-sql-baseline-plans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hotsos Symposium 2012</title>
		<link>http://kerryosborne.oracle-guy.com/2012/02/hotsos-symposium-2012/</link>
		<comments>http://kerryosborne.oracle-guy.com/2012/02/hotsos-symposium-2012/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 21:43:23 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3834</guid>
		<description><![CDATA[It&#8217;s almost time for Hotsos&#8217;s 10th annual Symposium. This year&#8217;s conference will be held March 4 &#8211; 8 in Irving, Texas. The Hotsos Symposium is probably the best performance oriented Oracle conferences in the world. I am happy and humbled to be speaking at it again this year as the lineup of speakers is once [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s almost time for <a href="http://www.hotsos.com/sym12.html">Hotsos&#8217;s 10th annual Symposium</a>. This year&#8217;s conference will be held March 4 &#8211; 8 in Irving, Texas. The Hotsos Symposium is probably the best performance oriented Oracle conferences in the world. I am happy and humbled to be <a href="http://www.hotsos.com/sym12/sym_speakers_osborne.html">speaking</a> at it again this year as the lineup of speakers is once again world class. It&#8217;s great to have several other <a href="www.enkitec.com">Enkitec&#8217;ies</a> on the bill as well. Both <a href="http://karenmorton.blogspot.com/">Karen Morton</a> and <a href="http://blog.tanelpoder.com/">Tanel Poder</a> will be presenting too. Enkitec is also a sponsor of the event this year, so we&#8217;ll be hosting a couple of Exadata focused happy hours as well. There&#8217;s still time to <a href="http://www.hotsos.com/sym12/sym_reg.html">register</a>. Hope to see you there.</p>
<p>&nbsp;</p>
<p><a href="http://www.hotsos.com/sym12.html"><img class="aligncenter size-full wp-image-3835" title="Hotsos_logo_2012" src="http://kerryosborne.oracle-guy.com/files/2012/02/Hotsos_logo_2012.jpg" alt="" width="203" height="114" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2012/02/hotsos-symposium-2012/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Upcoming Speaking Engagements</title>
		<link>http://kerryosborne.oracle-guy.com/2012/02/upcoming-speaking-engagements/</link>
		<comments>http://kerryosborne.oracle-guy.com/2012/02/upcoming-speaking-engagements/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 02:14:20 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3830</guid>
		<description><![CDATA[I&#8217;ll be speaking at a couple of conferences over the next month or so. Here&#8217;s the schedule: February 16th, in Denver at RMOUG Training Days 2012 - Topic: DIY Exadata February 23rd, in Redwood Shores at NoCOUG Winter Conference - Topic: DIY Exadata March 7th, in Dallas at Hotsos Symposium 2012 - Topic: Exadata Optimization &#8211; Case Studies Hope [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be speaking at a couple of conferences over the next month or so. Here&#8217;s the schedule:</p>
<p>February 16th, in Denver at <a href="http://www.rmoug.org/training.htm">RMOUG Training Days 2012</a> - Topic: <a href="http://www.technicalconferencesolutions.com/pls/caat/caat_abstract_reports.display_presenter_abstract?conference_id=99&amp;presenter_id=353&amp;abstract_id=296183">DIY Exadata</a><br />
February 23rd, in Redwood Shores at <a href="http://www.technicalconferencesolutions.com/pls/caat/caat_abstract_reports.schedule?conference_id=106">NoCOUG Winter Conference</a> - Topic: <a href="http://www.technicalconferencesolutions.com/pls/caat/caat_abstract_reports.display_presenter_abstract?conference_id=106&amp;presenter_id=480&amp;abstract_id=300175">DIY Exadata</a><br />
March 7th, in Dallas at <a href="http://www.hotsos.com/sym12.html">Hotsos Symposium 2012</a> - Topic: <a href="http://www.hotsos.com/sym12/sym_speakers_osborne.html">Exadata Optimization &#8211; Case Studies</a></p>
<p>Hope to see you at one of these events.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2012/02/upcoming-speaking-engagements/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C. J. Date Speaking in Dallas</title>
		<link>http://kerryosborne.oracle-guy.com/2012/01/c-j-date-speaking-in-dallas/</link>
		<comments>http://kerryosborne.oracle-guy.com/2012/01/c-j-date-speaking-in-dallas/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 00:56:31 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3806</guid>
		<description><![CDATA[Chris Date is one of the founding fathers of relational databases. Having worked with Ted Codd at IBM during the time when relational databases were being defined gives Chris a perspective that most of us just don&#8217;t have. I&#8217;ve had the good fortune to hear him speak in the past (at the Hotsos Symposium) and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Christopher_J._Date">Chris Date</a> is one of the founding fathers of relational databases. Having worked with Ted Codd at IBM during the time when relational databases were being defined gives Chris a perspective that most of us just don&#8217;t have. I&#8217;ve had the good fortune to hear him speak in the past (at the <a href="http://www.hotsos.com/sym12.html">Hotsos Symposium</a>) and thought I would do a quick post to highlight the fact that he is scheduled to speak in Dallas the week of Jan 30. <a href="http://method-r.com/">Method-R</a> is hosting the event in the <a href="http://www.enkitec.com">Enkitec</a> training facilities in Dallas. So maybe I&#8217;ll get to hang around with Chris and Cary that week &#8211; that would be cool! Anyway, there are actually 2 classes:</p>
<p><a href="http://methodr20120130.eventbrite.com/">SQL and Relational Theory: How to Write Accurate SQL Code</a><br />
<a href="http://methodr20120202.eventbrite.com/"> Normal Forms and All That Jazz: a Database Professional’s Guide to Database Design Theory</a></p>
<p>And here&#8217;s a link to the registration page:   <a href="http://methodr20120130cjdate.eventbrite.com/">C. J. Date Seminar Registration</a></p>
<p>By the way, I think every developer and every database architect should have a clear understanding of how the SQL language is designed to work and how relational databases were intended to be laid out. Chris obviously has a unique insight into those topics. One of the tenants of Chris&#8217;s teaching is that SQL is a complicated language and since comprehensive testing is almost never really feasible, it is important to write SQL using a disciplined approach based on the underlying relational theory. As a side note, I was talking to a few cohorts around the coffee pot today and was shocked to hear that one of the guys had a CS degree but was not required to take a relational theory class. Back when I got started that was the first class that people took, probably because there were almost no real implementations of the theory at that point. Oracle was just getting started and DB2 was still a distant gleam in Mr. Codd&#8217;s eye. But I digress.</p>
<p>It does seem to me that we have an awful lot of systems running on Oracle these days that were designed and written by people without a strong background in relational database fundamentals. I can&#8217;t even begin to count the number of times I&#8217;ve worked on systems that performed poorly due to poor SQL coding techniques and/or poor database design. Chris&#8217;s courses are designed to help you avoid these issues. So this is your chance to learn how to know for sure that your SQL is correct.</p>
<p>Hope to you see you there!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2012/01/c-j-date-speaking-in-dallas/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Christmas Explain Plan Patterns</title>
		<link>http://kerryosborne.oracle-guy.com/2011/12/christmas-explain-plan-patterns/</link>
		<comments>http://kerryosborne.oracle-guy.com/2011/12/christmas-explain-plan-patterns/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 20:44:37 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3790</guid>
		<description><![CDATA[Here&#8217;s a lovely Candy Striped pattern in an Explain Plan. Looks like the traditional Christmas candy canes. Just in time for the Holiday Season! ?View Code NONE&#124; 156 &#124; FAST DUAL &#124; &#124; 1 &#124; &#124; 2 (0)&#124; 00:00:01 &#124; &#124; 157 &#124; FAST DUAL &#124; &#124; 1 &#124; &#124; 2 (0)&#124; 00:00:01 &#124; &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a lovely Candy Striped pattern in an Explain Plan. Looks like the traditional Christmas candy canes. Just in time for the Holiday Season!</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3790code4'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p37904"><td class="code" id="p3790code4"><pre class="none" style="font-family:monospace;">| 156 |     FAST DUAL                                                |                                |     1 |       |     2   (0)| 00:00:01 |
| 157 |      FAST DUAL                                               |                                |     1 |       |     2   (0)| 00:00:01 |
| 158 |       FAST DUAL                                              |                                |     1 |       |     2   (0)| 00:00:01 |
| 159 |        FAST DUAL                                             |                                |     1 |       |     2   (0)| 00:00:01 |
| 160 |         FAST DUAL                                            |                                |     1 |       |     2   (0)| 00:00:01 |
| 161 |          FAST DUAL                                           |                                |     1 |       |     2   (0)| 00:00:01 |
| 162 |           FAST DUAL                                          |                                |     1 |       |     2   (0)| 00:00:01 |
| 163 |            FAST DUAL                                         |                                |     1 |       |     2   (0)| 00:00:01 |
| 164 |             FAST DUAL                                        |                                |     1 |       |     2   (0)| 00:00:01 |
| 165 |              FAST DUAL                                       |                                |     1 |       |     2   (0)| 00:00:01 |
| 166 |               FAST DUAL                                      |                                |     1 |       |     2   (0)| 00:00:01 |
| 167 |                FAST DUAL                                     |                                |     1 |       |     2   (0)| 00:00:01 |
| 168 |                 FAST DUAL                                    |                                |     1 |       |     2   (0)| 00:00:01 |
| 169 |                  FAST DUAL                                   |                                |     1 |       |     2   (0)| 00:00:01 |
| 170 |                   FAST DUAL                                  |                                |     1 |       |     2   (0)| 00:00:01 |
| 171 |                    FAST DUAL                                 |                                |     1 |       |     2   (0)| 00:00:01 |
| 172 |                     FAST DUAL                                |                                |     1 |       |     2   (0)| 00:00:01 |
| 173 |                      FAST DUAL                               |                                |     1 |       |     2   (0)| 00:00:01 |
| 174 |                       FAST DUAL                              |                                |     1 |       |     2   (0)| 00:00:01 |
| 175 |                        FAST DUAL                             |                                |     1 |       |     2   (0)| 00:00:01 |
| 176 |                         FAST DUAL                            |                                |     1 |       |     2   (0)| 00:00:01 |
| 177 |                          FAST DUAL                           |                                |     1 |       |     2   (0)| 00:00:01 |
| 178 |                           FAST DUAL                          |                                |     1 |       |     2   (0)| 00:00:01 |
| 179 |                            FAST DUAL                         |                                |     1 |       |     2   (0)| 00:00:01 |
| 180 |                             FAST DUAL                        |                                |     1 |       |     2   (0)| 00:00:01 |
| 181 |                              FAST DUAL                       |                                |     1 |       |     2   (0)| 00:00:01 |
| 182 |                               FAST DUAL                      |                                |     1 |       |     2   (0)| 00:00:01 |
| 183 |                                FAST DUAL                     |                                |     1 |       |     2   (0)| 00:00:01 |
| 184 |                                 FAST DUAL                    |                                |     1 |       |     2   (0)| 00:00:01 |
| 185 |                                  FAST DUAL                   |                                |     1 |       |     2   (0)| 00:00:01 |
| 186 |                                   FAST DUAL                  |                                |     1 |       |     2   (0)| 00:00:01 |
| 187 |                                    FAST DUAL                 |                                |     1 |       |     2   (0)| 00:00:01 |
| 188 |                                     FAST DUAL                |                                |     1 |       |     2   (0)| 00:00:01 |
| 189 |                                      FAST DUAL               |                                |     1 |       |     2   (0)| 00:00:01 |
| 190 |                                       FAST DUAL              |                                |     1 |       |     2   (0)| 00:00:01 |
| 191 |                                        FAST DUAL             |                                |     1 |       |     2   (0)| 00:00:01 |
| 192 |                                         FAST DUAL            |                                |     1 |       |     2   (0)| 00:00:01 |
| 193 |                                          FAST DUAL           |                                |     1 |       |     2   (0)| 00:00:01 |
| 194 |                                           FAST DUAL          |                                |     1 |       |     2   (0)| 00:00:01 |
| 195 |                                            FAST DUAL         |                                |     1 |       |     2   (0)| 00:00:01 |
| 196 |                                             FAST DUAL        |                                |     1 |       |     2   (0)| 00:00:01 |
| 197 |                                              FAST DUAL       |                                |     1 |       |     2   (0)| 00:00:01 |
| 198 |                                               FAST DUAL      |                                |     1 |       |     2   (0)| 00:00:01 |
| 199 |                                                FAST DUAL     |                                |     1 |       |     2   (0)| 00:00:01 |
| 200 |                                                 FAST DUAL    |                                |     1 |       |     2   (0)| 00:00:01 |
| 201 |                                                  FAST DUAL   |                                |     1 |       |     2   (0)| 00:00:01 |
| 202 |                                                   FAST DUAL  |                                |     1 |       |     2   (0)| 00:00:01 |
| 203 |                                                    FAST DUAL |                                |     1 |       |     2   (0)| 00:00:01 |
| 204 | L                                                   FAST DUA |                                |     1 |       |     2   (0)| 00:00:01 |
| 205 | AL                                                   FAST DU |                                |     1 |       |     2   (0)| 00:00:01 |
| 206 | UAL                                                   FAST D |                                |     1 |       |     2   (0)| 00:00:01 |
| 207 | DUAL                                                   FAST  |                                |     1 |       |     2   (0)| 00:00:01 |
| 208 |  DUAL                                                   FAST |                                |     1 |       |     2   (0)| 00:00:01 |
| 209 | T DUAL                                                   FAS |                                |     1 |       |     2   (0)| 00:00:01 |
| 210 | ST DUAL                                                   FA |                                |     1 |       |     2   (0)| 00:00:01 |
| 211 | AST DUAL                                                   F |                                |     1 |       |     2   (0)| 00:00:01 |
| 212 |.FAST DUAL                                                    |                                |     1 |       |     2   (0)| 00:00:01 |
| 213 |. FAST DUAL                                                   |                                |     1 |       |     2   (0)| 00:00:01 |
| 214 |.  FAST DUAL                                                  |                                |     1 |       |     2   (0)| 00:00:01 |
| 215 |.   FAST DUAL                                                 |                                |     1 |       |     2   (0)| 00:00:01 |
| 216 |.    FAST DUAL                                                |                                |     1 |       |     2   (0)| 00:00:01 |
| 217 |.     FAST DUAL                                               |                                |     1 |       |     2   (0)| 00:00:01 |
| 218 |.      FAST DUAL                                              |                                |     1 |       |     2   (0)| 00:00:01 |
| 219 |.       FAST DUAL                                             |                                |     1 |       |     2   (0)| 00:00:01 |
| 220 |.        FAST DUAL                                            |                                |     1 |       |     2   (0)| 00:00:01 |
| 221 |.         FAST DUAL                                           |                                |     1 |       |     2   (0)| 00:00:01 |
| 222 |.          FAST DUAL                                          |                                |     1 |       |     2   (0)| 00:00:01 |
| 223 |.           FAST DUAL                                         |                                |     1 |       |     2   (0)| 00:00:01 |
| 224 |.            FAST DUAL                                        |                                |     1 |       |     2   (0)| 00:00:01 |
| 225 |.             FAST DUAL                                       |                                |     1 |       |     2   (0)| 00:00:01 |
| 226 |.              FAST DUAL                                      |                                |     1 |       |     2   (0)| 00:00:01 |
| 227 |.               FAST DUAL                                     |                                |     1 |       |     2   (0)| 00:00:01 |
| 228 |.                FAST DUAL                                    |                                |     1 |       |     2   (0)| 00:00:01 |
| 229 |.                 FAST DUAL                                   |                                |     1 |       |     2   (0)| 00:00:01 |
| 230 |.                  FAST DUAL                                  |                                |     1 |       |     2   (0)| 00:00:01 |
| 231 |.                   FAST DUAL                                 |                                |     1 |       |     2   (0)| 00:00:01 |
| 232 |.                    FAST DUAL                                |                                |     1 |       |     2   (0)| 00:00:01 |
| 233 |.                     FAST DUAL                               |                                |     1 |       |     2   (0)| 00:00:01 |
| 234 |.                      FAST DUAL                              |                                |     1 |       |     2   (0)| 00:00:01 |
| 235 |.                       FAST DUAL                             |                                |     1 |       |     2   (0)| 00:00:01 |</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2011/12/christmas-explain-plan-patterns/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tuning Oracle to Make a Query Slower</title>
		<link>http://kerryosborne.oracle-guy.com/2011/11/tuning-oracle-to-make-a-query-slower/</link>
		<comments>http://kerryosborne.oracle-guy.com/2011/11/tuning-oracle-to-make-a-query-slower/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 19:15:20 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Exadata]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Tuning]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3760</guid>
		<description><![CDATA[I had an interesting little project this morning. Of course it takes longer to write it down than to do actually do it, but it was kind of interesting and since I haven&#8217;t done a post in quite some time (and it&#8217;s the day before Thanksgiving, so it&#8217;s pretty quite at the office anyway) I [...]]]></description>
			<content:encoded><![CDATA[<p>I had an interesting little project this morning. Of course it takes longer to write it down than to do actually do it, but it was kind of interesting and since I haven&#8217;t done a post in quite some time (and it&#8217;s the day before Thanksgiving, so it&#8217;s pretty quite at the office anyway) I decided to share.   One of the Enkitec guys (Tim Fox) was doing a performance comparison between various platforms (Exadata using it&#8217;s IB Storage Network, Oracle Database Appliance (ODA) using it&#8217;s direct attached storage, and a standard database on a Dell box using EMC fiber channel attached storage). The general test idea was simple &#8211; see how the platforms stacked up for a query that required a full scan of a large table. More specifically, what Tim wanted to see was the relative speed at which the various storage platforms could return data. The expectation was that the direct attached storage would be fastest and the fibre channel storage would be slowest (especially since we only had a single 2G HBA). He tested ODA and Exadata and got basically what he expected, but when he went to test the database on the Dell he was surprised that it was actually faster than either of the other two tests.   So here&#8217;s some output from the initial tests:  First the Exadata. It&#8217;s an X2 quarter rack with one extra storage server. Note that we had to set cell_offload_processing to false to turn off the Exadata storage optimizations, thus giving us a measurement of the hardware capabilities without the Exadata offloading.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3760code10'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p376010"><td class="code" id="p3760code10"><pre class="none" style="font-family:monospace;">&gt; !sqlp
sqlp
&nbsp;
SQL*Plus: Release 11.2.0.2.0 Production on Wed Nov 23 11:08:28 2011
&nbsp;
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
&nbsp;
&nbsp;
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
&nbsp;
SYS@DEMO1&gt; @uptime
&nbsp;
INSTANCE_NAME    STARTUP_TIME      CURRENT_TIME         DAYS    SECONDS
---------------- ----------------- ----------------- ------- ----------
DEMO1            07-NOV-2011 12:37 23-NOV-2011 11:08   15.94    1377058
&nbsp;
SYS@DEMO1&gt; set sqlprompt &quot;_USER'@'EXADATA'&gt;' &quot;
SYS@EXADATA&gt; 
SYS@EXADATA&gt; ! cat /etc/redhat-release
Enterprise Linux Enterprise Linux Server release 5.5 (Carthage)
&nbsp;
SYS@EXADATA&gt; ! uname -a
Linux enkdb03.enkitec.com 2.6.18-194.3.1.0.3.el5 #1 SMP Tue Aug 31 22:41:13 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
&nbsp;
SYS@EXADATA&gt; alter session set &quot;_serial_direct_read&quot;=always;
&nbsp;
Session altered.
&nbsp;
SYS@EXADATA&gt; alter session set cell_offload_processing=false;
&nbsp;
Session altered.
&nbsp;
SYS@EXADATA&gt; set autotrace on
SYS@EXADATA&gt; set timing on
SYS@EXADATA&gt; select count(*) from instructor.class_sales;
&nbsp;
  COUNT(*)
----------
  90000000
&nbsp;
Elapsed: 00:00:43.01
&nbsp;
Execution Plan
----------------------------------------------------------
Plan hash value: 3145879882
&nbsp;
----------------------------------------------------------------------------------
| Id  | Operation                  | Name        | Rows  | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT           |             |     1 |   314K  (1)| 00:00:02 |
|   1 |  SORT AGGREGATE            |             |     1 |            |          |
|   2 |   TABLE ACCESS STORAGE FULL| CLASS_SALES |    90M|   314K  (1)| 00:00:02 |
----------------------------------------------------------------------------------
&nbsp;
&nbsp;
Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
    1168567  consistent gets
    1168557  physical reads
          0  redo size
        526  bytes sent via SQL*Net to client
        524  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed
&nbsp;
SYS@EXADATA&gt; set autotrace off
SYS@EXADATA&gt; @fss
Enter value for sql_text: select count(*) from instructor.class_sales
Enter value for sql_id: 
&nbsp;
SQL_ID         CHILD      EXECS   AVG_ROWS     AVG_ETIME       AVG_CPU       AVG_PIO      AVG_LIO SQL_TEXT
------------- ------ ---------- ---------- ------------- ------------- ------------- ------------ ----------------------------------------
b2br1x82p9862      0          1          1         43.00          3.16  1,168,557.00    1,168,567 select count(*) from instructor.class_sa
&nbsp;
Elapsed: 00:00:00.08</pre></td></tr></table></div>

<p>So the test on the Exadata took 43 seconds to read and transport roughly 1 million 8K blocks.  The same test on the ODA looked like this: <span id="more-3760"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3760code11'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p376011"><td class="code" id="p3760code11"><pre class="none" style="font-family:monospace;">[oracle@patty scripts]$ !rl rlwrap sqlplus / as sysdba  
&nbsp;
SQL*Plus: Release 11.2.0.2.0 Production on Wed Nov 23 10:16:51 2011  
&nbsp;
Copyright (c) 1982, 2010, Oracle.  All rights reserved.   
&nbsp;
&nbsp;
Connected to: 
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production 
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, 
Data Mining and Real Application Testing options   
&nbsp;
INSTANCE_NAME    STARTUP_TIME               CURRENT_TIME                  DAYS    SECONDS 
---------------- -------------------------- -------------------------- ------- ---------- 
ODA1             22-NOV-2011 12:23          23-NOV-2011 10:16              .91      78793  
&nbsp;
SYS@ODA1&gt; ! cat /etc/redhat-release 
&nbsp;
Red Hat Enterprise Linux Server release 5.5 (Tikanga)  
&nbsp;
SYS@ODA1&gt; ! uname -a 
&nbsp;
Linux patty 2.6.18-194.32.1.0.1.el5 #1 SMP Tue Jan 4 16:26:54 EST 2011 x86_64 x86_64 x86_64 GNU/Linux  
&nbsp;
SYS@ODA1&gt; set timing on
&nbsp;
SYS@ODA1&gt; alter session set '_serial_direct_read'=always;  
&nbsp;
Session altered.  
&nbsp;
Elapsed: 00:00:00.00 
&nbsp;
SYS@ODA1&gt; set autotrace on 
SYS@ODA1&gt; select count(*) from instructor.class_sales;    
&nbsp;
COUNT(*) 
----------   
90000000  
Elapsed: 00:00:30.60  
&nbsp;
Execution Plan 
---------------------------------------------------------- 
Plan hash value: 3145879882  
&nbsp;
-------------------------------------------------------------------------- 
| Id  | Operation          | Name        | Rows  | Cost (%CPU)| Time     | 
-------------------------------------------------------------------------- 
|   0 | SELECT STATEMENT   |             |     1 |   317K  (1)| 00:00:05 | 
|   1 |  SORT AGGREGATE    |             |     1 |            |          | 
|   2 |   TABLE ACCESS FULL| CLASS_SALES |    90M|   317K  (1)| 00:00:05 | 
--------------------------------------------------------------------------   
&nbsp;
&nbsp;
Statistics 
----------------------------------------------------------          
        99  recursive calls           
         0  db block gets     
   1154080  consistent gets     
   1153994  physical reads         
       516  redo size         
       526  bytes sent via SQL*Net to client         
       524  bytes received via SQL*Net from client           
         2  SQL*Net roundtrips to/from client           
         7  sorts (memory)           
         0  sorts (disk)           
         1  rows processed  
&nbsp;
SYS@ODA1&gt; set autotrace off 
SYS@ODA1&gt; @fss 
Enter value for sql_text: select count(*) from instructor.class_sales 
Enter value for sql_id:   
&nbsp;
SQL_ID         CHILD PLAN_HASH_VALUE      EXECS ROWS_PROCESSED  AVG_ETIME    AVG_CPU    AVG_PIO    AVG_LIO SQL_TEXT 
------------- ------ --------------- ---------- -------------- ---------- ---------- ---------- ---------- ---------------------------------------- 
b2br1x82p9862      0      3145879882          1              1      30.55      13.91  1,153,994  1,154,080 select count(*) from instructor.class_sa</pre></td></tr></table></div>

<p>As expected, the direct attached disk was faster than moving the blocks across the IB network. It took about 30 seconds to read roughly the same number of blocks.  The same test on the Dell produced this output:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3760code12'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p376012"><td class="code" id="p3760code12"><pre class="none" style="font-family:monospace;"> [osborne@homer scripts]$ sqlp  
&nbsp;
SQL*Plus: Release 11.2.0.3.0 Production on Wed Nov 23 11:20:20 2011  
&nbsp;
Copyright (c) 1982, 2011, Oracle.  All rights reserved.   
&nbsp;
&nbsp;
Connected to: 
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
With the Partitioning, OLAP, Data Mining and Real Application Testing options  
&nbsp;
SYS@EXADATA&gt; set sqlprompt &quot;'_USER'@'DELL'&gt;'&quot; 
SYS@DELL&gt; !cat /etc/redhat-release 
&nbsp;
Red Hat Enterprise Linux Server release 5.5 (Tikanga)  
&nbsp;
SYS@DELL&gt; ! uname -a 
&nbsp;
Linux homer.enkitec.com 2.6.18-194.el5 #1 SMP Mon Mar 29 22:10:29 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux  
&nbsp;
SYS@DELL&gt; alter session set '_serial_direct_read'=always;  
&nbsp;
Session altered.  
&nbsp;
SYS@DELL&gt; set autotrace on 
&nbsp;
SYS@DELL&gt; set timing on 
&nbsp;
SYS@DELL&gt; select count(*) from instructor.class_sales;    
&nbsp;
COUNT(*) 
----------   
90000000  
&nbsp;
Elapsed: 00:00:11.31  
&nbsp;
Execution Plan 
---------------------------------------------------------- 
Plan hash value: 3145879882  
&nbsp;
-------------------------------------------------------------------------- 
| Id  | Operation          | Name        | Rows  | Cost (%CPU)| Time     | 
-------------------------------------------------------------------------- 
|   0 | SELECT STATEMENT   |             |     1 |   315K  (1)| 01:03:08 | 
|   1 |  SORT AGGREGATE    |             |     1 |            |          | 
|   2 |   TABLE ACCESS FULL| CLASS_SALES |    90M|   315K  (1)| 01:03:08 | 
--------------------------------------------------------------------------   
&nbsp;
&nbsp;
Statistics ----------------------------------------------------------          
        77  recursive calls  
         0  db block gets  
   1168660  consistent gets  
   1168569  physical reads  
         0  redo size  
       526  bytes sent via SQL*Net to client  
       524  bytes received via SQL*Net from client  
         2  SQL*Net roundtrips to/from client  
        10  sorts (memory)  
         0  sorts (disk)  
         1  rows processed  
&nbsp;
SYS@DELL&gt; set autotrace off 
SYS@DELL&gt; @fss 
Enter value for sql_text: select count(*) from instructor.class_sales 
Enter value for sql_id:   
&nbsp;
SQL_ID         CHILD      EXECS   AVG_ROWS     AVG_ETIME       AVG_CPU       AVG_PIO      AVG_LIO SQL_TEXT 
------------- ------ ---------- ---------- ------------- ------------- ------------- ------------ ---------------------------------------- 
b2br1x82p9862      0          1          1         11.29         11.25  1,168,569.00    1,168,660 select count(*) from instructor.class_sa  
&nbsp;
Elapsed: 00:00:00.03</pre></td></tr></table></div>

<p>This is where the results were surprising. Tim expected the single 2G HBA to be considerably slower than the other two set ups, but it only took 11 seconds on the Dell / EMC set up to read the same data. So this is where I got to help Tim try to make it slower! (there&#8217;s a first time for everything)  So what gives?   The first thought was that Oracle was caching the data:  But no &#8211; you&#8217;ll notice that we set the _serial_direct_read parameter to always, which forces direct path reads and bypasses the buffer cache altogether. Also, the stats bear out that Oracle is doing physical reads. But 1 Million real i/o&#8217;s can&#8217;t happen in 11 seconds so it&#8217;s got to be memory access right? (I&#8217;m sure you&#8217;re way ahead of me by now)   The answer of course is &quot;Right &#8211; it is memory access!&quot; &#8211; but it&#8217;s the Linux file system cache not the Oracle buffer cache.  A quick check of the Linux memory usage showed us that the file cache was over 20G and the table was less than 10G. So Oracle must be set up without Direct I/O.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3760code13'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p376013"><td class="code" id="p3760code13"><pre class="none" style="font-family:monospace;">SYS@DELL&gt; !cat /proc/meminfo 
&nbsp;
MemTotal:     32948892 kB 
MemFree:       2769420 kB 
Buffers:        615664 kB 
Cached:       24727756 kB 
SwapCached:     101844 kB 
Active:       21322184 kB 
Inactive:      5261948 kB 
HighTotal:           0 kB 
HighFree:            0 kB 
LowTotal:     32948892 kB 
LowFree:       2769420 kB 
SwapTotal:    34996216 kB 
SwapFree:     34147776 kB 
Dirty:             448 kB 
Writeback:           0 kB 
AnonPages:     1138828 kB 
Mapped:        4758828 kB 
Slab:          1088356 kB 
PageTables:     167464 kB 
NFS_Unstable:        0 kB 
Bounce:              0 kB 
CommitLimit:  51470660 kB 
Committed_AS: 15637340 kB 
VmallocTotal: 34359738367 kB 
VmallocUsed:    371108 kB 
VmallocChunk: 34359367199 kB 
HugePages_Total:     0 
HugePages_Free:      0 
HugePages_Rsvd:      0 
Hugepagesize:     2048 kB  
&nbsp;
SYS@DELL&gt; !realfreemem.sh -a 
&nbsp;
Free Memory: 2703M 
Cached Memory: 24148M 
Total Free Memory: 26851M 
Total Memory: 32176M 
Percent Memory Free (including cache): 83%  
&nbsp;
SYS@DELL&gt; @table_size 
Enter value for owner: INSTRUCTOR 
Enter value for table_name: CLASS_SALES 
Enter value for type:   
&nbsp;
OWNER                SEGMENT_NAME                   TYPE               TOTALSIZE_MEGS TABLESPACE_NAME 
-------------------- ------------------------------ ------------------ -------------- ------------------------------ 
INSTRUCTOR           CLASS_SALES                    TABLE                     9,151.0 ODACOMP_DATA 
                                                                       -------------- 
sum                                                                           9,151.0  
&nbsp;
Elapsed: 00:00:00.04
&nbsp;
SYS@DELL&gt; -- so how is Oracle configured for I/O? 
SYS@DELL&gt; @parms 
Enter value for parameter: filesys 
Enter value for isset:  
Enter value for show_hidden:   
&nbsp;
NAME                                               VALUE                                                                  ISDEFAUL ISMODIFIED ISSET 
-------------------------------------------------- ---------------------------------------------------------------------- -------- ---------- ---------- 
filesystemio_options                               NONE                                                                   TRUE     FALSE      FALSE  
&nbsp;
Elapsed: 00:00:00.01</pre></td></tr></table></div>

<p>So the database was not configured to use direct i/o or async i/o (filesystemio_options=none). A quick check with strace verified that direct i/o was not being used. So we modified the filesystemio_options setting and tried again.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3760code14'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p376014"><td class="code" id="p3760code14"><pre class="none" style="font-family:monospace;">SYS@DELL&gt; alter system set filesystemio_options=setall scope=spfile;  
&nbsp;
System altered.  
&nbsp;
SYS@DELL&gt; startup force 
ORACLE instance started.  
&nbsp;
Total System Global Area 4910620672 bytes 
Fixed Size                  2236648 bytes 
Variable Size            2298482456 bytes 
Database Buffers         2600468480 bytes 
Redo Buffers                9433088 bytes 
Database mounted. Database opened. 
&nbsp;
SYS@ODACOMP&gt;  
SYS@ODACOMP&gt; @uptime  
&nbsp;
INSTANCE_NAME    STARTUP_TIME               CURRENT_TIME                  DAYS    SECONDS 
---------------- -------------------------- -------------------------- ------- ---------- 
ODACOMP          23-NOV-2011 12:45          23-NOV-2011 12:47              .00        121  
&nbsp;
SYS@ODACOMP&gt; set sqlprompt &quot;'_USER'@'DELL'&gt;'&quot; 
SYS@DELL&gt;
SYS@DELL&gt; ! cat /etc/redhat-release 
&nbsp;
Red Hat Enterprise Linux Server release 5.5 (Tikanga)  
&nbsp;
SYS@DELL&gt; ! uname -a 
&nbsp;
Linux homer.enkitec.com 2.6.18-194.el5 #1 SMP Mon Mar 29 22:10:29 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux  
&nbsp;
SYS@DELL&gt; set timing on 
SYS@DELL&gt; alter session set '_serial_direct_read'=always;  
&nbsp;
Session altered.  
&nbsp;
Elapsed: 00:00:00.00
&nbsp;
SYS@DELL&gt; set autotrace on 
&nbsp;
SYS@DELL&gt; select count(*) from instructor.class_sales;    
&nbsp;
COUNT(*) 
----------   
90000000  
&nbsp;
Elapsed: 00:01:39.73  
&nbsp;
Execution Plan 
---------------------------------------------------------- 
Plan hash value: 3145879882  
&nbsp;
-------------------------------------------------------------------------- 
| Id  | Operation          | Name        | Rows  | Cost (%CPU)| Time     | 
-------------------------------------------------------------------------- 
|   0 | SELECT STATEMENT   |             |     1 |   315K  (1)| 01:03:08 | 
|   1 |  SORT AGGREGATE    |             |     1 |            |          | 
|   2 |   TABLE ACCESS FULL| CLASS_SALES |    90M|   315K  (1)| 01:03:08 | 
--------------------------------------------------------------------------   
&nbsp;
&nbsp;
Statistics ----------------------------------------------------------  
         1  recursive calls  
         0  db block gets  
   1168567  consistent gets  
   1168557  physical reads  
         0  redo size  
       526  bytes sent via SQL*Net to client  
       524  bytes received via SQL*Net from client  
         2  SQL*Net roundtrips to/from client  
         0  sorts (memory)  
         0  sorts (disk)  
         1  rows processed  
&nbsp;
SYS@DELL&gt; set autotrace off 
SYS@DELL&gt; @fss 
Enter value for sql_text: select count(*) from instructor.class_sales 
Enter value for sql_id:   
&nbsp;
SQL_ID         CHILD      EXECS   AVG_ROWS     AVG_ETIME       AVG_CPU       AVG_PIO      AVG_LIO SQL_TEXT 
------------- ------ ---------- ---------- ------------- ------------- ------------- ------------ ---------------------------------------- 
b2br1x82p9862      0          1          1         99.71          7.32  1,168,557.00    1,168,567 select count(*) from instructor.class_sa  
&nbsp;
Elapsed: 00:00:00.05</pre></td></tr></table></div>

<p>Ah that&#8217;s more like it. Roughly 100 seconds now to complete the query. That&#8217;s 10X slower. Nice job. It feels so good when you can make something go slower. ;)  I should note that in general, it is a very good idea to set filesystemio_options=SETALL. So please don&#8217;t jump to the conclusion that setting this parameter to NONE will make your database run faster. These days, the memory is generally better used by Oracle than by the file system cache. Glenn Fawcett has <a href="http://blogs.oracle.com/glennf/entry/where_do_you_cache_oracle">a good (if somewhat dated) post</a> which compares the effects of caching blocks in the file system cache vs. in the Oracle buffer cache in Solaris. As you might image, allowing Oracle to use the memory is generally more effective as shown in his results.  So that&#8217;s it for today. By the way, this post took 4 times as long to write as the actual testing took. Maybe I&#8217;ll get better at it if I start practicing a little more often.</p>
]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2011/11/tuning-oracle-to-make-a-query-slower/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Oracle Database Appliance &#8211; (Baby Exadata?)</title>
		<link>http://kerryosborne.oracle-guy.com/2011/09/oracle-database-appliance/</link>
		<comments>http://kerryosborne.oracle-guy.com/2011/09/oracle-database-appliance/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 20:59:19 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Oracle Database Appliance]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3722</guid>
		<description><![CDATA[Oracle today announced a new database appliance product. It&#8217;s called Oracle Database Appliance (ODA). I&#8217;m not crazy about the name, but I really like the product. Here&#8217;s a picture of the one in Enkitec&#8217;s lab: &#124; &#124; The project was code named &#8220;Comet&#8221; &#8211; thus the yellow sticky note. ;) I really like that name [...]]]></description>
			<content:encoded><![CDATA[<p>Oracle today announced a new database appliance product. It&#8217;s called Oracle Database Appliance (ODA). I&#8217;m not crazy about the name, but I really like the product. Here&#8217;s a picture of the one in Enkitec&#8217;s lab:<br />
|<a href="http://kerryosborne.oracle-guy.com/files/2011/09/Comet.jpg"><img class="aligncenter size-full wp-image-3724" title="Comet" src="http://kerryosborne.oracle-guy.com/files/2011/09/Comet.jpg" alt="" width="640" height="480" /></a><br />
|<br />
The project was code named &#8220;Comet&#8221; &#8211; thus the yellow sticky note. ;)</p>
<p>I really like that name better than ODA, so I think I will just stick with Comet.</p>
<p>Enkitec participated in the beta test program for the product and we  were very impressed, particularly with the speed at which the product  could be deployed and configured. There is a new tool called the &#8220;OAK Configurator&#8221; that is sort like the Exadata OneCommand for configuring the system. Keep an eye out for <a href="http://karlarao.wordpress.com/">Karl Arao</a>&#8216;s upcoming post with screen shots of the tool in action.</p>
<p>I&#8217;m sure there will be plenty of people talking about the specs so I won&#8217;t get carried away with that. But I will tell you that it&#8217;s basically 4 terrabytes of usable storage, 2 node RAC with up to 24 cores and a SSD component that is used for improving redo write speeds (more on that later), all in a 4U chassis. Andy Colvin has already got a really good post on the <a href="http://blog.oracle-ninja.com/2011/09/inside-the-oracle-database-appliance-part-1/"> </a><a href="http://blog.oracle-ninja.com/2011/09/inside-the-oracle-database-appliance-part-1/">hardware components that are included in the Oracle Database Appliance</a> (along with pictures of the bits and bobs inside the chassis).</p>
<p>I should point out that while I have heard people refer to Comet as a &#8220;Baby Exadata&#8221;, I really don&#8217;t view it that way. That&#8217;s because it DOES NOT have separate storage and compute tiers. So there is no Exadata Smart Scan / Offloading secret sauce here. It also does not provide the ability to utilize Exadata&#8217;s Hybrid Columnar Compression. On the other hand, like Exadata, it is a pre-configured and tested system that can be dropped in a data center and be ready for use almost immediately (it took us only a couple of hours to set it up and create a database). Pretty unbelievable really.</p>
<p>So much like my favorite Bill Clinton quote, whether ODA is a &#8220;Baby Exadata&#8221; or not, really depends on your definition of the word &#8220;is&#8221;. It is a hardware platform that is built specifically to run Oracle databases, but it does not embed any of the unique Exadata software components. Nevertheless, it is an extremely capable platform that will appeal to wide variety of companies running Oracle databases.</p>
<p>And best of all, the list price for this puppy is only $50K. I predict this thing is going to sell like hot cakes!</p>
]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2011/09/oracle-database-appliance/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Funny Developer Tricks &#8211; Decode</title>
		<link>http://kerryosborne.oracle-guy.com/2011/09/funny-developer-tricks-decode/</link>
		<comments>http://kerryosborne.oracle-guy.com/2011/09/funny-developer-tricks-decode/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 22:25:16 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Wall of Shame]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3704</guid>
		<description><![CDATA[I ran into a really ugly SQL statement last week. It was the most expensive statement running on the system for the last several weeks. On top of the fact that the statement ran for hours, it also had a number of &#8220;issues&#8221;. The statement had the following characteristics: Several DISTINCT Operators &#8211; these tend [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a really ugly SQL statement last week. It was the most expensive statement running on the system for the last several weeks. On top of the fact that the statement ran for hours, it also had a number of &#8220;issues&#8221;. The statement had the following characteristics:</p>
<ul>
<li><strong>Several DISTINCT Operators</strong> &#8211; these tend to show up in statements where developers have left off a join condition</li>
<li><strong>ANSI Join Syntax</strong> &#8211; generally Oracle converts this syntax back to Oracle join syntax under the covers. I realize this is standard SQL syntax, but it still makes me nervous due to previous experience with problems caused by this conversion process.</li>
<li><strong>Functions Used in WHERE Clauses (DECODE and NVL in particular)</strong> &#8211; can disable indexes</li>
<li><strong>UNION</strong> &#8211; forces a sort of the union&#8217;ed result sets so that it can eliminate duplicates (which is often not necessary). Depending on how the statement is coded, UNIONs can also sometimes result in multiple accesses of the same objects (i.e. if the developer has used the UNION in the place of a more robust where clause).</li>
<li><strong>Numerous != and &lt;&gt; Comparison Operators</strong> &#8211; Not necessarily a problem but often can be coded in a more efficient manner</li>
<li><strong>Several OR&#8217;s</strong> &#8211; OR&#8217;s are tricky. I get suspicious when there are numerous other problems in a statement as well.</li>
</ul>
<p>I&#8217;ll refrain from publishing the actual statement to protect the guilty, but one of the most interesting bits of the statement looked something like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3704code19'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p370419"><td class="code" id="p3704code19"><pre class="none" style="font-family:monospace;">...
WHERE a.col1 =  DECODE ('XYZ', '*', a.col1 ,'XYZ')
...</pre></td></tr></table></div>

<p>The processing of the where clause can be roughly translated to the following psuedo code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3704code20'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p370420"><td class="code" id="p3704code20"><pre class="none" style="font-family:monospace;">&nbsp;
if 'XYZ' = '*' then 
  x = a.col1
else
  x = 'XYZ'
end if
&nbsp;
...
WHERE a.col1 = x
...</pre></td></tr></table></div>

<p>Since the literal &#8216;XYZ&#8217; will never be equal to the literal &#8216;*&#8217;, the value returned by this DECODE will always be &#8216;XYZ&#8217;. Therefore the statement could have been written much more simply as:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3704code21'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p370421"><td class="code" id="p3704code21"><pre class="none" style="font-family:monospace;">...
WHERE a.col1 = 'XYZ'
...</pre></td></tr></table></div>

<p>So this is an extremely strange way to write the statement and clouds the intention considerably, but does it hurt performance? Well actually no. The optimizer is smart enough to know that this DECODE will always result in the same literal value and so it appears that Oracle does not run the DECODE statement for each row. Here&#8217;s a quick example from a 10.2.0.4 database. (note that I used <a href="http://kerryosborne.oracle-guy.com/scripts/dplan.sql">dplan.sql</a> and <a href="http://kerryosborne.oracle-guy.com/scripts/fss.sql">fss.sql</a> in this code snippet)</p>
<p><span id="more-3704"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3704code22'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p370422"><td class="code" id="p3704code22"><pre class="none" style="font-family:monospace;">&nbsp;
SYS@LAB1024&gt; -- first a DECODE that actually does something
SYS@LAB1024&gt; select count(pk_col) from kso.skew where col2 = DECODE(col1,1,col2,'asd');
&nbsp;
COUNT(PK_COL)
-------------
      3199971
&nbsp;
Elapsed: 00:00:06.62
SYS@LAB1024&gt; @fss
Enter value for sql_text: select count(pk_col) from kso.skew where col2 = DECODE(col1,1,col2,'asd')
Enter value for sql_id: 
&nbsp;
SQL_ID         CHILD      EXECS   AVG_ROWS     AVG_ETIME       AVG_CPU       AVG_PIO      AVG_LIO SQL_TEXT
------------- ------ ---------- ---------- ------------- ------------- ------------- ------------ ----------------------------------------
45ynyjvg6hyyh      0          1          1          6.46          6.41    111,029.00      162,298 select count(pk_col) from kso.skew where
&nbsp;
Elapsed: 00:00:00.07
SYS@LAB1024&gt; @dplan
Enter value for sql_id: 45ynyjvg6hyyh
Enter value for child_no: 
&nbsp;
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  45ynyjvg6hyyh, child number 0
-------------------------------------
select count(pk_col) from kso.skew where col2 =
DECODE(col1,1,col2,'asd')
&nbsp;
Plan hash value: 568322376
&nbsp;
---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |     4 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |    16 |            |          |
|*  2 |   TABLE ACCESS FULL| SKEW |  1234 | 19744 |     4   (0)| 00:00:01 |
---------------------------------------------------------------------------
&nbsp;
Predicate Information (identified by operation id):
---------------------------------------------------
&nbsp;
   2 - filter(&quot;COL2&quot;=DECODE(&quot;COL1&quot;,1,&quot;COL2&quot;,'asd'))
&nbsp;
&nbsp;
20 rows selected.
&nbsp;
Elapsed: 00:00:00.06
SYS@LAB1024&gt; -- Now one that is equivalent to WHERE col2 = 'asddsadasd'
SYS@LAB1024&gt; select count(pk_col) from kso.skew where col2 = DECODE('asddsadasd','*', col2, 'asddsadasd');
&nbsp;
COUNT(PK_COL)
-------------
     32000000
&nbsp;
Elapsed: 00:00:03.88
SYS@LAB1024&gt; @fss
Enter value for sql_text: select count(pk_col) from kso.skew where col2 = DECODE('asddsadasd','*', col2, 'asddsadasd')
Enter value for sql_id: 
&nbsp;
SQL_ID         CHILD      EXECS   AVG_ROWS     AVG_ETIME       AVG_CPU       AVG_PIO      AVG_LIO SQL_TEXT
------------- ------ ---------- ---------- ------------- ------------- ------------- ------------ ----------------------------------------
4u3nbf55z1ztd      0          1          1          3.88          3.88    111,054.50      162,298 select count(pk_col) from kso.skew where
&nbsp;
Elapsed: 00:00:00.07
SYS@LAB1024&gt; @dplan 
Enter value for sql_id: 4u3nbf55z1ztd
Enter value for child_no: 
&nbsp;
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  4u3nbf55z1ztd, child number 0
-------------------------------------
select count(pk_col) from kso.skew where col2 =
DECODE('asddsadasd','*', col2, 'asddsadasd')
&nbsp;
Plan hash value: 568322376
&nbsp;
---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |     4 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |    11 |            |          |
|*  2 |   TABLE ACCESS FULL| SKEW |  1234 | 13574 |     4   (0)| 00:00:01 |
---------------------------------------------------------------------------
&nbsp;
Predicate Information (identified by operation id):
---------------------------------------------------
&nbsp;
   2 - filter(&quot;COL2&quot;='asddsadasd')
&nbsp;
&nbsp;
20 rows selected.
&nbsp;
Elapsed: 00:00:00.01</pre></td></tr></table></div>

<p>As you can see, the unnecessary DECODE ran much faster and if you look closely at the Predicate Information sections of the plans you&#8217;ll see that the unnecessary DECODE filter was converted to &#8220;COL2&#8243;=&#8217;asddsadasd&#8217;. That&#8217;s pretty cool.</p>
<p>Unfortunately, whether the DECODE slows down the processing is not the biggest issue. It&#8217;s highly probable that the developer thought this DECODE was doing something other than what it&#8217;s actually doing and thus that the result produced by this statement is incorrect. But that&#8217;s a story for another day.</p>
]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2011/09/funny-developer-tricks-decode/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Mastering Oracle Trace Data</title>
		<link>http://kerryosborne.oracle-guy.com/2011/08/mastering_oracle_trace_data/</link>
		<comments>http://kerryosborne.oracle-guy.com/2011/08/mastering_oracle_trace_data/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 13:58:21 +0000</pubDate>
		<dc:creator>osborne</dc:creator>
				<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=3687</guid>
		<description><![CDATA[Cary Millsap is teaching a new one day class next week in Dallas (well Southlake actually) on Oracle trace data. This is a class that he has personally been working on recently and is teaching. I am planning on attending. Here&#8217;s a link to the sign up page which has all the details: Mastering Oracle [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://carymillsap.blogspot.com/">Cary Millsap</a> is teaching a new one day class next week in Dallas (well Southlake actually) on Oracle trace data. This is a class that he has personally been working on recently and is teaching. I am planning on attending. Here&#8217;s a link to the sign up page which has all the details: </p>
<p><a href="http://methodr20110823.eventbrite.com/">Mastering Oracle Trace Data</a></p>
<p>Check it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://kerryosborne.oracle-guy.com/2011/08/mastering_oracle_trace_data/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

