<?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>Toine van Beckhoven&#039;s Oracle blog</title>
	<atom:link href="http://toinevanbeckhoven.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://toinevanbeckhoven.wordpress.com</link>
	<description>General Oracle Database blog</description>
	<lastBuildDate>Wed, 18 Jan 2012 14:18:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='toinevanbeckhoven.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/8c92f241740bb10ce32a70cdc756970d?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Toine van Beckhoven&#039;s Oracle blog</title>
		<link>http://toinevanbeckhoven.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://toinevanbeckhoven.wordpress.com/osd.xml" title="Toine van Beckhoven&#039;s Oracle blog" />
	<atom:link rel='hub' href='http://toinevanbeckhoven.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Installation of Oracle 11 Release 2 on Windows 7 64-bit</title>
		<link>http://toinevanbeckhoven.wordpress.com/2011/03/18/installation-of-oracle-11-release-2-on-windows-7-64-bit/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2011/03/18/installation-of-oracle-11-release-2-on-windows-7-64-bit/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 22:31:13 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Oracle administration]]></category>
		<category><![CDATA[Performance and Troubleshooting]]></category>
		<category><![CDATA[Administrative Privileges]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[LSNRCTL]]></category>
		<category><![CDATA[ORA-12541]]></category>
		<category><![CDATA[ORA-12560]]></category>
		<category><![CDATA[Oracle 11R2]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows Service]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=181</guid>
		<description><![CDATA[I never had so much trouble installing an Oracle version on a Windows OS as I had with installation of Oracle 11R2 on Windows 7 (64-bit). The issues I faced were twofold: First I got messages (during installation of the software) that files could not be found in the target oracle folder Second, after finding [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=181&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I never had so much trouble installing an Oracle version on a Windows OS as I had with installation of Oracle 11R2 on Windows 7 (64-bit). The issues I faced were twofold:</p>
<ol>
<li>First I got messages (during installation of the software) that files could not be found in the target oracle folder</li>
<li>Second, after finding the solution for the first annoyance, I spent two hours finding out why everything installed correctly, I could create a database, but could not start a Listener. I am an Administrator on my laptop. The errors I got at starting a listener were ORA-12560 and ORA-12541.</li>
</ol>
<p><span id="more-181"></span><span style="color:#ff0000;">Regarding 1:</span></p>
<p>It appeared to be very simple: when you download Oracle 11 R2, there are two zip files. Make sure to extract both zip files into the same folder and not into two separate folders (like a Disk1 and Disk2 folder). After extracting both zip files into the same folder, the installation went smooth without errors.</p>
<p><span style="color:#ff0000;">Regarding 2:</span></p>
<p>After a fresh installation and creation of a database, I am used to open a Command prompt, start LSNRCTL, and execute a START to start the default listener. If a Windows Service does not exist yet, LSNRCTL throws some errors around that but as part of this it creates the Windows Service. But not this time. I kept on getting the result:</p>
<pre>C:\&gt;lsnrctl start
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 18-MRT-2011 21:48:56
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
Starten van tnslsnr: Even geduld a.u.b.
TNS-12560: TNS: fout bij protocoladapter.
 TNS-00530: Fout in protocoladapter.</pre>
<p>and a LSNRCTL status gave me:</p>
<pre>C:\&gt;lsnrctl status
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 18-MRT-2011 21:52:02
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
Verbinding wordt gemaakt met (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.1)(PORT=1521))).
TNS-12541: TNS: geen listener.
 TNS-12560: TNS: fout bij protocoladapter.
  TNS-00511: Geen listener
   64-bit Windows Error: 61: Unknown error
C:\&gt;</pre>
<p>But no listener got created. The Oracle support site, nor any forum or blog pointed me in the correct direction. The only thought I had was: I know Windows requires the Listener to be present as a Service, so as long as that is not the case, it will not start. So here is what I tried: I created the service myself using the Windows &#8220;sc&#8221; command. Now a first attempt gave an Access Denied, but after storing the command in a Batch file and executing the batch file to &#8220;Run as Administrator&#8221; (right-click the command file and choose that option), the service got created!</p>
<p>The SC command used was: <em>sc create OracleOraDb11g_home1TNSListener binPath= &#8220;C:\app\toine\product\11.2.0\dbhome_1\BIN\TNSLSNR.exe&#8221;</em> (take care of the space after binPath= !)</p>
<p>And after starting it using the Service Control Panel, LSNRCTL gave me a good status:</p>
<pre>C:\&gt;lsnrctl status
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 18-MRT-2011 21:57:57
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
Verbinding wordt gemaakt met (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.1)(PORT=1521))).
STATUS van LISTENER
------------------------
Alias                            LISTENER
Versie                           TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
Startdatum                       18-MRT-2011 21:57:48
Ingeschakeld                     0 dagen 0 uren 0 minuten 9 seconden
Traceerniveau                    support
Beveiliging                      ON: Local OS Authentication
SNMP                             OFF
Parameterbestand van listener   C:\app\toine\product\11.2.0\dbhome_1\network\admin\listener.ora.
Log van listener            c:\app\toine\product\11.2.0\dbhome_1\log\diag\tnslsnr\mypc\listener\alert\log.xml
Traceerbestand van listener c:\app\toine\product\11.2.0\dbhome_1\log\diag\tnslsnr\mypc\listener\trace\ora_6728_7012.trc
Overzicht beluisteren eindpunten...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=1.1.1.1)(PORT=1521)))
Overzicht van services...
Service "ONTW112. MYPC.MYDOMAIN.NL" heeft 1 instance(s).
  Instance "ONTW112", toestand UNKNOWN, heeft 1 handler(s) voor deze service...
Uitvoeren van opdracht is geslaagd.
 </pre>
<p>and I could login using Oracle Net <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
The problem appeared to be Administrative privileges. Which was not obvious to me at first. I wondered why the installer could create all necessary services, whereas LSNRCTL was not able to create the Listener service. I stopped and deleted the service again (using &#8220;sc delete&#8221;) and started LSNRCTL.EXE as Administrator (go to the Oracle\bin folder and right click LSNRCTL.EXE. That lead to the same result: a START within that LSNRCTL session created the Windows Service as I am used to from other Oracle installations on Windows I did many times.</p>
<p>After all it is probably a logical error on Windows 7.  What bugs me is that I did not read it somewhere and that the errors did not point me to the problem. They pointed me towards some network problem. I almost wonder whether I missed some guideline. Still, it may help others, who have the same trouble.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/181/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=181&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2011/03/18/installation-of-oracle-11-release-2-on-windows-7-64-bit/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>
	</item>
		<item>
		<title>How to deal with DBMS_RLS</title>
		<link>http://toinevanbeckhoven.wordpress.com/2011/02/07/how-to-deal-with-dbms_rls/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2011/02/07/how-to-deal-with-dbms_rls/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 20:56:40 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Oracle administration]]></category>
		<category><![CDATA[SQL and PL/SQL]]></category>
		<category><![CDATA[DBMS_RLS]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Row Level Security]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[VPD]]></category>
		<category><![CDATA[wrapper packages]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=163</guid>
		<description><![CDATA[DBMS_RLS is a powerfull, but necessary package to create VPD enabled applications. This article shows a way to grant VPD management to developers without the danger of hurting someone else's policies<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=163&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>How to deal with DBMS_RLS?</h1>
<p> </p>
<p>These last weeks I am trying to get the VPD option (Virtual Private Database) enabled for my application. This time as a developer with no DBA or SYS privileges. I am used to being a DBA for the databases I work on and am used to being able to get the fullest out of the Oracle database. For one, because I think Oracle provides us with a great deal of built-in features that do things more efficiently than we can do ourselves (more efficient, built-in kernel code) and also especially because it seems useless and time-consuming to write code that is already supplied by built-in packages. Now these provided features may not all be as intuitive as we want to or lack some important features, but that is where we can spend some time extending them or making them more user-friendly by creating “wrapper” packages: packages you write that hide the complexity or unfriendliness of a built-in package or limit the features you can use. Because there are quite some packages out there that contain functions or procedures or even parameters that you do not want to give to your developers or end users.<span id="more-163"></span></p>
<p>An example of such a package that is too powerful to grant to your end-users as a whole is DBMS_RLS. This package enables you to put Row Level Security (and even Column Level Security) on your schema objects. When you take a look at most tutorials available about the VPD option, all of them simply state that you should grant EXECUTE on DBMS_RLS to the schema owner so that it can add, drop, enable, disable policies on its objects to limit the data an end-user of the object can see or manipulate.</p>
<p>First, I love the feature. It is a way of declaratively filtering data based on business criteria dependent on the logged in user/location/terminal/anything that can be set or queried as a context variable. It is so much cleaner than having the same kind of predicates sitting around in all parts of the application, almost knowing for sure that:</p>
<ul>
<li>something will have been missed somewhere and people see data they should not</li>
<li>or will change in the future and turns in to a maintenance nightmare</li>
<li>or can be circumvented</li>
</ul>
<p>Why is DBMS_RLS too powerful in “my” opinion? At least I made it my opinion also after consulting with a DBA at the company where I need the VPD feature, who knows what it is like to manage several hundreds of databases and knows the challenge of maintaining some level of standardization without compromising security but on the other hand providing application developers with a toolset they can solve their problems with. I did not think of it at first when asking for EXECUTE privileges on DBMS_RLS for my application, but he mentioned that DBMS_RLS is not preventing me from hurting someone else’s policies:</p>
<p>If a database contains schema owners SCOTT and TOINE and both need VPD for their schema objects…the tutorials state that both should get execute privileges on DBMS_RLS. But that does not prevent SCOTT from dropping policies of user TOINE. Me as TOINE would hate the idea that someone else can touch my ‘rules’. As it turns out there is more about securing DBMS_RLS that goes beyond this simple article (SQL Injection and XMLDB or some other built-in packages can dig a hole into your beautiful VPD security, see for such an example <a href="http://www.oracle-dox.net/Wiley-The.Oracle.Hacker.s.Hand/final/BBL0043.html" target="_blank">http://www.oracle-dox.net/Wiley-The.Oracle.Hacker.s.Hand/final/BBL0043.html</a> or Pete Finnigan’s presentation <a href="http://www.petefinnigan.com/Oracle_Security_VPD_2009_6slides.pdf" target="_blank">http://www.petefinnigan.com/Oracle_Security_VPD_2009_6slides.pdf</a>). Also there is a lot of useful information to be found for a hacker in a number of data dictionary views.</p>
<p>So how would a DBA that needs to standardize hundreds of databases enable a developer to use DBMS_RLS? Several options, one better than the other:</p>
<ul>
<li>He or she could execute any policy manipulation (enable/disable/add/drop) on behalf of the developer. This requires tickets to be raised and will frustrate the developer who has to wait for the DBA to find time to execute that task out of his growing queue of such tasks</li>
<li>I like the wrapper package idea: create a wrapper package on top of DBMS_RLS, it can be as simple as providing all subprograms, but then WITHOUT the object_schema parameter. Instead of having the developer provide the object_schema, YOU take control and allow that developer to only manipulate policies on objects of its own. Instead of a grant EXECUTE on DBMS_RLS, a grant EXECUTE on the wrapper package is provided.</li>
</ul>
<p>So DBMS_RLS looks like (In Oracle 10R2):</p>
<pre>CREATE OR REPLACE PACKAGE SYS.dbms_rls AS
  STATIC                     CONSTANT   BINARY_INTEGER := 1;
  SHARED_STATIC              CONSTANT   BINARY_INTEGER := 2;
  CONTEXT_SENSITIVE          CONSTANT   BINARY_INTEGER := 3;
  SHARED_CONTEXT_SENSITIVE   CONSTANT   BINARY_INTEGER := 4;
  DYNAMIC                    CONSTANT   BINARY_INTEGER := 5;
  DV_INTERNAL                CONSTANT   BINARY_INTEGER := 10;
  ALL_ROWS                   CONSTANT   BINARY_INTEGER := 1;

  PROCEDURE add_policy(object_schema   IN VARCHAR2 := NULL,
                       object_name     IN VARCHAR2,
                       policy_name     IN VARCHAR2,
                       function_schema IN VARCHAR2 := NULL,
                       policy_function IN VARCHAR2,
                       statement_types IN VARCHAR2 := NULL,
                       update_check    IN BOOLEAN  := FALSE,
                       enable          IN BOOLEAN  := TRUE,
                       static_policy   IN BOOLEAN  := FALSE,
                       policy_type     IN BINARY_INTEGER := NULL,
                       long_predicate BOOLEAN  := FALSE,
                       sec_relevant_cols IN VARCHAR2  := NULL,
                       sec_relevant_cols_opt IN BINARY_INTEGER := NULL); 

  PROCEDURE drop_policy(object_schema IN VARCHAR2 := NULL,
                        object_name   IN VARCHAR2,
                        policy_name   IN VARCHAR2);

[intentionally left out the rest of subprograms)
END dbms_rls;
/</pre>
<p>A wrapper package, which can be created in any DBA managed schema (it might be a dedicated VPD admin schema) could look like:</p>
<pre>CREATE OR REPLACE PACKAGE <span style="color:#ff0000;">VPDADMIN</span>.<span style="color:#ff0000;">secure<strong>_</strong>dbms_rls </span>AS
  STATIC                     CONSTANT   BINARY_INTEGER := 1;
  SHARED_STATIC              CONSTANT   BINARY_INTEGER := 2;
  CONTEXT_SENSITIVE          CONSTANT   BINARY_INTEGER := 3;
  SHARED_CONTEXT_SENSITIVE   CONSTANT   BINARY_INTEGER := 4;
  DYNAMIC                    CONSTANT   BINARY_INTEGER := 5;
  DV_INTERNAL                CONSTANT   BINARY_INTEGER := 10; 
  ALL_ROWS                   CONSTANT   BINARY_INTEGER := 1;

  PROCEDURE add_policy(object_name   IN VARCHAR2,
                       policy_name     IN VARCHAR2,
                       function_schema IN VARCHAR2 := NULL,
                       policy_function IN VARCHAR2,
                       statement_types IN VARCHAR2 := NULL,
                       update_check    IN BOOLEAN  := FALSE,
                       enable          IN BOOLEAN  := TRUE,
                       static_policy   IN BOOLEAN  := FALSE,
                       policy_type     IN BINARY_INTEGER := NULL,
                       long_predicate BOOLEAN  := FALSE,
                       sec_relevant_cols IN VARCHAR2  := NULL,
                       sec_relevant_cols_opt IN BINARY_INTEGER := NULL);

  PROCEDURE drop_policy(object_name   IN VARCHAR2,
                        policy_name   IN VARCHAR2);

  [intentionally left out the rest of subprograms)
END dbms_rls;
/ </pre>
<p>In the body of this package the subprograms can simply call DBMS_RLS. Add_policy and drop_policy like this:</p>
<pre>CREATE OR REPLACE PACKAGE BODY <span style="color:#ff0000;">VPDADMIN.secure<strong>_</strong>dbms_rls </span>AS
     PROCEDURE add_policy(object_name   IN VARCHAR2,
                          policy_name     IN VARCHAR2,
                          function_schema IN VARCHAR2 := NULL,
                          policy_function IN VARCHAR2,
                          statement_types IN VARCHAR2 := NULL,
                          update_check    IN BOOLEAN  := FALSE,
                          enable          IN BOOLEAN  := TRUE,
                          static_policy   IN BOOLEAN  := FALSE,
                          policy_type     IN BINARY_INTEGER := NULL,
                          long_predicate BOOLEAN  := FALSE,
                          sec_relevant_cols IN VARCHAR2  := NULL,
                          sec_relevant_cols_opt IN BINARY_INTEGER := NULL)
  IS
   BEGIN
     <span style="color:#ff0000;">sys.dbms_rls.add_policy</span>(<span style="color:#ff0000;">USER</span>,
                             object_name,
                             policy_name,
                             function_schema,
                             policy_function,
                             statement_types,
                             update_check,
                             enable,
                             static_policy,
                             policy_type,
                             long_predicate,
                             sec_relevant_cols,
                             sec_relevant_cols_opt);
   END; 
  [intentionally left out the rest of subprograms)
END dbms_rls;
/ </pre>
<p>The only disadvantage I can think of is portability of the code: if the target database is not following the same principle, you would have to alter your package name. But if you call your add_policy program using named parameters instead of positional…then the package name may be the only thing you would have to change…since DBMS_RLS takes the current user as the default if none is provided:</p>
<pre>BEGIN
   <span style="color:#ff0000;">VPDADMIN.secure_dbms_rls</span>.add_policy
                             (object_name          =&gt; 'mytable',
                              policy_name          =&gt; 'mypolicy',
                              function_schema      =&gt; 'myschema',
                              policy_function      =&gt; 'mypackage.myfunction',
                              statement_types      =&gt; 'select, update, delete'
                             );
END;</pre>
<p>I am currently in the middle of discussing this wrapper option&#8230;I hope to be able to use VPD as wanted soon. Anyone feeling differently on grants on DBMS_RLS?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=163&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2011/02/07/how-to-deal-with-dbms_rls/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>
	</item>
		<item>
		<title>Catching up…presenting and taking part in Challenges</title>
		<link>http://toinevanbeckhoven.wordpress.com/2010/06/14/catching-up-presenting-and-taking-part-in-challenges/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2010/06/14/catching-up-presenting-and-taking-part-in-challenges/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 19:22:35 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Performance and Troubleshooting]]></category>
		<category><![CDATA[Cary Millsap]]></category>
		<category><![CDATA[Oracle User Group]]></category>
		<category><![CDATA[PL/SQL Challenge]]></category>
		<category><![CDATA[presenting]]></category>
		<category><![CDATA[tuning]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=155</guid>
		<description><![CDATA[I regret not being able to write new things more often, but in fact it only means I am OK: very busy with work, doing private stuff (which is important since life is not all about working), enjoying the three young kids and trying to achieve some good results in track and field. And for that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=155&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I regret not being able to write new things more often, but in fact it only means I am OK: very busy with work, doing private stuff (which is important since life is not all about working), enjoying the three young kids and trying to achieve some good results in track and field. And for that last goal, I can say I did. After a few months of struggling to find a tiny piece of shape comparable to last years shape, just in time I found it. I won the gold medal in the Dutch Championships 400 metres hurdles. OK, be honest, for the &#8216;older&#8217; men (40+). Still, my time was certainly not bad and about 2 seconds ahead of all other competitors of 35 years and older. And it brought me back in the top 30 of all Dutch 400 metres hurdles runners (Juniors and Seniors) in 2010. Nice. Just as nice was that I met Alex Nuijten (Amis) who volunteered there and even wrote about it on this <a title="Alex Nuijten blog" href="http://nuijten.blogspot.com/2010/06/analytic-function-bug-and-national.html" target="_blank">nice blog</a>. Thanks Alex.<span id="more-155"></span></p>
<p>I am probably in worse shape this year because I spend so much time doing things like the <a title="PL/SQL Challenge" href="http://www.plsqlchallenge.com" target="_blank">PL/SQL Challenge</a>  and doing a presentation for the Dutch User Group on Performance Tuning and Troubleshooting. Ofcourse the first one is mostly fun and it does not take so much time: the statistics on the site even show clearly how much time I needed to answer all those questions so far (it started the 8th of April). It is a superb idea worked out by <a title="Ellebaek Consulting" href="http://www.ellebaek-consulting.com/" target="_blank">Finn Elebaek Nielsen</a> and  <a title="Steven Feuerstein" href="http://www.stevenfeuerstein.com" target="_blank">Steven Feuerstein</a>, whom I got to know rather well in the last decade since I used to work intensively with his PL/Generator and invited him a few times for the Dutch User Group. Great guy and very enthusiastic about spreading the word of PL/SQL. It encourages me to play at my best in this Challenge and so far I am doing much better than expected (currently in second place and have been in first place for several days). And we are reaching Quarter&#8217;s end, meaning the top players will do a play-off to decide who will be 1st, 2nd and 3rd. And these will win some serious cash prices. It is serious stuff <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  and I hope to be able to be in that top 10 to give it a shot.<a href="http://toinevanbeckhoven.files.wordpress.com/2010/06/plsqlsmall3.jpg"><img class="alignright size-full wp-image-160" title="plsqlsmall3" src="http://toinevanbeckhoven.files.wordpress.com/2010/06/plsqlsmall3.jpg" alt="" width="250" height="100" /></a></p>
<p>The second thing, the presentation for the Dutch User Group, was at May 26 where I was able to talk to almost 100 Oracle minded people. An unexpected high number of people subscribed for my presentation. Not often a waiting list is needed for this monthly event, where the User Group invites a speaker on a certain topic. This time it was about Database Performance Tuning and Troubleshooting and they found me on LinkedIn. I can only say: it seems to work and to pay off to have a profile on such a social network. Even though I am not fond of exposing on all kinds of social networks, I find LinkedIn an almost &#8220;must have&#8221; for professional people. But that is very personal and I know people who stay away from it as far as possible. But for me it works. So I was invited to speak about Database Tuning. Since I do not do presentations that often, I did not have a ready-made set of slides yet and all you people who present once and a while know how much energy this takes. I must say it was in my head almost 24*7. Oh yes, I was thinking of ways to present this with this joke and to present that with that joke and I was having a lot of fun before I fell asleep each night. I know, it sounds sad, especially since I seemed to forget about all those jokes as soon as I thought of a new one. Is that the age-thing&#8230;? As said earlier, I have reached my 40&#8242;s. It was so bad that I almost wanted to start with the sentence: &#8220;If I remembered all the jokes I had in mind for this evening, you people would have had a splendid and joyful evening!&#8221; Now, reality was that it became much more serious than that. I kept the jokes to an acceptable minimum <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Still I think I kept almost all attendees awake for almost 2,5 hours and got some nice feedback afterwards. To me it was a success  for a first &#8220;big&#8221; presentation and I had to battle against a beamer that did not want to recognize my Dell laptop. Which was a bit of a shame, since the prepared demo&#8217;s could only run on that laptop and not on the one I borrowed from a former colleague who was in the room.</p>
<p>I talked about several things that are important in my work as a Performance Troubleshooter. I included some highlevel thoughts for which I am mostly inspired by Cary Millsap and his great book &#8220;Oracle Performance Tuning&#8221;, but also from his Masterclass. By that I mean things like doing diagnosis in the proper scope and not being blinded by averages and totals that make real performance problems invisable. But also that I feel a modern DBA and most certainly one that is involved in solving performance problems needs to communicate. Not only talk to other technical people (like developers), but also communicate with people in the business. They determine your priorities, since your priorities need to allign with the business priorities. Example: 1,5 years ago someone told me that we needed to focus on performance of some part of the system, since some dashboard showed a decreasing performance line. So we did some extra analysis and did not really find a performance problem. Users were also not complaining. Then I said I wanted to be able to talk to key users who could tell me their worst problems. It was a great thing: their impression of that &#8220;bad&#8221; part of the system was in fact the same as ours after that analysis: that part had no real performance problems according to all those users but most of them asked if we could have a similar conversation soon about a totally other part of the system which had some real bad problems. After all it turned out that &#8220;dashboard&#8221; that showed the so-called &#8220;performance problem&#8221; was not accurate: it was running on a laptop with performance problems of its own. Our communication with the users revealed no problem, but lead us to a part that we <em><strong>did</strong></em> need to look at and focus on. One for which we did not have an accurate performance monitor for. Without those users showing us their real problems, we would have focussed on the wrong part of the system. It can be that simple, sometimes.</p>
<p>For the rest I presented some more technical things:</p>
<ul>
<li>I told about some mysteries and fallacies of the optimizer (in which part I referred to Wolfgang Breitling&#8217;s &#8220;Tuning by cardinality&#8221;) and showed some fixes you can do when the optimizer cannot get it right</li>
<li>I talked about indexing strategy in an OLTP and OLAP system and showed some thoughts of Tapio Lahdenmäki (3-star indexes and the difference between single block reads and multi block reads)</li>
<li>And finally I had some slides on one of my personal favorites: clustering of data</li>
</ul>
<p>One of the backgrounds for the presentation was that I wanted to show things you can do when a system has problems, without immediately buying faster or more hardware. There is often so much you can achieve with simple solutions. Only well tuned systems are hard to tune, but in my experience and opinion, a great deal of systems out there are not even near being well-tuned. And there you can save a lot of money by having someone with Oracle knowledge and the ability to understand what the business wants and how the application works, take a look at your application. It becomes hard when the application itself is the biggest problem, but even a bad application can be helped with proper indexes, data clustering or optimizer related improvements, without touching the application itself.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/155/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=155&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2010/06/14/catching-up-presenting-and-taking-part-in-challenges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>

		<media:content url="http://toinevanbeckhoven.files.wordpress.com/2010/06/plsqlsmall3.jpg" medium="image">
			<media:title type="html">plsqlsmall3</media:title>
		</media:content>
	</item>
		<item>
		<title>One simple web page saved my day</title>
		<link>http://toinevanbeckhoven.wordpress.com/2010/01/28/one-simple-web-page-saved-my-day/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2010/01/28/one-simple-web-page-saved-my-day/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 14:31:20 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[Oracle administration]]></category>
		<category><![CDATA[opmn]]></category>
		<category><![CDATA[Oracle http server]]></category>
		<category><![CDATA[Oracle Http windows service]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=146</guid>
		<description><![CDATA[As an Oracle specialist you meet it from time to time: something is not working as expected. Lots of times the information is right under your hands on the web. We open Google and search for some error message we get. If I cannot find it there I open Oracle support (for some time already [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=146&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As an Oracle specialist you meet it from time to time: something is not working as expected. Lots of times the information is right under your hands on the web. We open Google and search for some error message we get. If I cannot find it there I open Oracle support (for some time already the flashy new site, I am getting used to it after a few weeks of hesitation and missing MetaLink). Probably it should be the other way around: Oracle problems should be explained best on the Oracle support site. And they probably are, but they are a logon away and a slow startup of the homepage, which makes a Google search a little quicker. And with all the blogs people keep up and other informational sites, many times a Google search is enough. Today I had a problem for which I could not find anything on the web as well as on the Oracle support site.<span id="more-146"></span></p>
<p>At one customer site we are migrating to Oracle 11 and we have an Oracle 9i database with a mod_plsql application to serve a dynamic webpage. Now if you are used to the HTTP server in Oracle8i or 9i installed by default together with the database software, you are wondering where it is after you install Oracle 10 and above. Now I knew that already so I knew I had to look at the Embedded PL/SQL Gateway or download and install the standalone Oracle HTTP server 10g from OTN. I started with the Embedded PL/SQL Gateway. It was not very hard to get it to work, but soon I realized it was not a substitute for the Apache web server in our case because we do not only have PL/SQL pages, but also static pages and the PL/SQL dynamic pages are just a part of the entire site.</p>
<p>So I downloaded the 10g standalone HTTP server from OTN. Great. I installed it and got it to work very fast (I knew where to look for configuration files and changes to make from my experience in 9i). I only wondered where my Windows Service was (Oh yes, it is a Windows environment), but I did not really take notice of it because I just thought the way the HTTP server was managed in 10g was different from 9i. This in the sense that you must use Oracle Process manager (OPMNctl) to start and stop the web server. And that worked indeed.</p>
<p>So everything was working, I had successfully upgraded the (test)web server to an Oracle 11.1.0.7 database and a 10.1 HTTP server and logged off from the server, but not before I sent an e-mail to the testers that the test site had moved and was accessible using the URL I gave them. I logged of and the next day I logged in to the network, tried the URL and it did not work. Huh? It worked yesterday. So I logged in to the server and used opmnctl to Start the HTTP server again. Now it worked again. I did not have time to check what the reason might be so I notified the testers that the webserver must have crashed or something and we would look at it tomorrow. I also showed that if it might happen again, she could start &#8216;opmctl startall&#8217; to at least be able to test the site (she is an administrator herself).</p>
<p>The next day the tester informed me that it did not work again and that even the opmnctl startall did not work. So the day after I started looking for reasons why the server was not started. I saw some SSL error, but that made no difference. And suddenly it appeared to me (stupid, I should have known): when I log off from the server, the HTTP processes were stopped because I started them under my control. The missing Windows Service seemed to be a key point here: the httpserver was not started as a service and I could not start it as a service, because the service was not there. And I wondered: how do I create that service? I could not find anything on the support site and at first nothing with a Google search. Mostly I stop looking after 2 or 3 pages of search results but this time I looked a bit further and there it was&#8230;my saving web page: <a title="DBA Portal" href="http://www.dbaportal.eu/?q=node/131" target="_blank">http://www.dbaportal.eu/?q=node/131</a>. I thought it would probably benefit more people so here is the clue:</p>
<ul>
<li>The standalone HTTP server on OTN does not create a Windows Service and this can be considered a bug</li>
<li>You can create the service yourself with the Windows SC command:</li>
</ul>
<pre>sc create OracleHTTPProcessManager binPath= "D:\ORACLE\ORAHTTP\opmn\bin\opmn.exe -S" DisplayName= OracleHTTPProcessManager start= auto</pre>
<p>You can choose a name for the Service and DisplayName yourself and the binPath must match your Oracle HTTP server installation&#8217;s opmn\bin folder.</p>
<p>And this hint was not in the article itself, but in a comment by the same author. Thank you! It is important that people show their problems and especially the answer. It &#8220;saved&#8221; my day&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=146&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2010/01/28/one-simple-web-page-saved-my-day/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle Import issues: Resumable and buffer</title>
		<link>http://toinevanbeckhoven.wordpress.com/2009/10/13/oracle-import-issues-resumable-and-buffer/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2009/10/13/oracle-import-issues-resumable-and-buffer/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 11:56:03 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[Backup and Recovery]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[resumable]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=139</guid>
		<description><![CDATA[Yesterday and today I noticed two things with Oracle import (in Oracle 10.2.0.4) I did not know: 1. An issue with the buffer parameter in Import 2. An issue with Resumable=Y and FROMUSER/TOUSER where the FROMUSER and TOUSER have different default tablespace and quotas Buffer I did a DIRECT export yesterday of a table that contains a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=139&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday and today I noticed two things with Oracle import (in Oracle 10.2.0.4) I did not know:</p>
<p>1. An issue with the buffer parameter in Import<br />
2. An issue with Resumable=Y and FROMUSER/TOUSER where the FROMUSER and TOUSER have different default tablespace and quotas<span id="more-139"></span></p>
<h2>Buffer</h2>
<ul>
<li>I did a DIRECT export yesterday of a table that contains a LONG column</li>
<li>I did an import (which is conventional) of that table with BUFFER=&lt;some value&gt;</li>
<li>I got embarrassed because my laptop started beeping around and my screen started screaming weird characters</li>
</ul>
<p>I went through that embarrassment a few times, because I tried twice with that same import file (only the foolish try the same thing twice and expect a different result, yes I am guilty <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ) and once with another import file of which I knew it contained that same table and I imported successfully in an 11g database earlier. (I almost thought I had a corrupt importfile and lost the contents of that table). But when that same import also initiated the terrible beeping (I have to turn of system beeps) and everybody in the large room was staring at me, I knew it had to be something with my import parameters. It turned out to be the buffer parameter. Even though that still surprises me. Oracle documentation says about buffer in IMPORT:</p>
<p><code>Default: operating system-dependent</code></p>
<p><code>The integer specified for BUFFER is the size, in bytes, of the buffer through which data rows are transferred.BUFFER determines the number of rows in the array inserted by Import. </code></p>
<p><code>The following formula gives an approximation of the buffer size that inserts a given array of rows: buffer_size = rows_in_array * maximum_row_size</code></p>
<p><code>For tables containing LOBs or <strong>LONG</strong>, BFILE, REF, ROWID, UROWID, or DATE columns, rows are inserted individually. <strong>The size of the buffer must be large enough to contain the entire row, except for LOB and LONG columns</strong>. <strong>If the buffer cannot hold the longest row in a table, Import attempts to allocate a larger buffer</strong>.</code></p>
<p>So I would have expected that Oracle would adjust the size of the buffer automatically when it turns out not to be big enough&#8230;</p>
<h2>Resumable</h2>
<p>I did an import for an entire schema into another schema (VIND into VINS). User VIND&#8217;s tables are in tablespace VIN_D. User VINS&#8217;s tables need to be created in tablespace VIN<strong>S</strong>_D. USER VINS has no quota on the tablespaces of user VIND. So the meaning is that IMPORT will create the tables (which are defined to be in tablespace VIN_D) into tablespace VINS_D. I have seen that working all the time in the past. Until this day when it did not work as expected. My import hung&#8230;it was due to the RESUMABLE=Y parameter I added to be able to handle out of space issues if they would occur.  But apparently RESUMABLE=Y and the need to import into a different tablespace without the hassle of pre-creating the tables first does not seem to work. It was not after I removed my RESUMABLE=Y that Import went ahead and created the tables in the default tablespace of user VINS.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=139&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2009/10/13/oracle-import-issues-resumable-and-buffer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>
	</item>
		<item>
		<title>DBMS_REDEFINITION, clustering and how an outline helps to make it completely ONLINE</title>
		<link>http://toinevanbeckhoven.wordpress.com/2009/09/23/127/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2009/09/23/127/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 20:23:51 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[Performance and Troubleshooting]]></category>
		<category><![CDATA[clustering]]></category>
		<category><![CDATA[dbms_redefinition]]></category>
		<category><![CDATA[outline]]></category>
		<category><![CDATA[rebuild tables]]></category>
		<category><![CDATA[Siebel]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=127</guid>
		<description><![CDATA[At last a new post from my hand after months of silence. Well, silence in writing then: in the mean time we got our third child and I participated in the World Championships Double Decathlon in Delft. Those two things were enough for me to handle next to regular work In this post I want [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=127&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At last a new post from my hand after months of silence. Well, silence in writing then: in the mean time we got our third child and I participated in the <a title="WC Double Decathlon" href="http://www.20kamp.nl">World Championships Double Decathlon </a>in Delft. Those two things were enough for me to handle next to regular work <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>In this post I want to share good experience I had in the use of DBMS_REDEFINITION to speed up the Siebel OLTP application I am responsible for (at least, for the performance part of it). It is about clustering of data and rebuilding tables as ONLINE as can be and how I used a trick with a stored outline to overcome a performance problem during rebuild of one table.<span id="more-127"></span></p>
<p>In every application there are certain tables that are queried heavily. Some applications have tables that are even used in almost every query. A lot of times the access path into these tables is concentrated around one or two columns or at least a few &#8220;important&#8221; columns. In Siebel for example there is a table called S_POSTN_CON, which stores links between Contacts (Professionals) and Positions. A Sales Representative for a certain product can be a &#8220;position&#8221; and a District manager is another &#8220;position&#8221;. The Contacts they are allowed to &#8216;see&#8217; (visibility) is defined by assignment rules and these assignment rules are the driving force for the contents of the S_POSTN_CON table and its counterpart for Organizations (Accounts), S_ACCNT_POSTN &#8211; Don&#8217;t you love such &#8220;standardization&#8221;, why not S_POSTN_ACCNT?). An extreme lot of queries join S_POSTN_CON or S_ACCNT_POSTN with other tables, to control the Contacts and Accounts the logged in user is allowed to see. These tables are always accessed using the POSTN_ID, which is the Siebel ID for the position the logged in user has.</p>
<p>A lot has been written already on the topic of data clustering in Oracle and why it is beneficial from a performance perspective (for example Jonathan Lewis: <a title="Data cluster" href="http://jonathanlewis.wordpress.com/2007/05/17/data-cluster/" target="_blank">http://jonathanlewis.wordpress.com/2007/05/17/data-cluster/</a>). It touches things like the clustering factor for Indexes and the db_file_sequential_read statistic. To be short: it really helps if the data you are after is clustered in a few Oracle blocks instead of spread over many blocks, especially when an index is used to get the data from the table. That is because the most expensive part of using an index is not the index access itself, but visiting the table to get the data blocks containing the rows identified by the index. Provided that all the data needed cannot be retrieved from the index alone (another good thing to look at). The more different blocks that need to be retrieved (using single block reads), the longer the execution time.</p>
<p>So with that in mind, we started looking at the &#8216;key&#8217; tables (the heavily used tables) in the Siebel OLTP application and looked at their most common access paths. As said for S_POSTN_CON and S_ACCNT_POST it was definitely the POSTN_ID column. And for example the S_CONTACT_XM table was accessed mostly via the PAR_ROW_ID (the link between the S_CONTACT_XM records and the S_CONTACT table, which stores the Contacts/Professionals) and the TYPE column.</p>
<p>Now what we did was a rebuild of these tables and we pre-sorted them on the access path columns. In that way, Oracle stores the table data sorted (well initially, it does not maintain it afterwards when new records enter the table) which means related data is stored tightly in as few Oracle blocks as possible. Which means: when S_POSTN_CON is queried for all the records for a given POSTN_ID, Oracle uses the index on S_POSTN_CON to get the rowid&#8217;s for the records with that POSTN_ID and only needs to get one or at most 2 or 3 Table blocks for all the records, instead of 20 or more blocks it needed to get before the rebuild.</p>
<p>The results were significant. A lot of queries became 50% or even a lot faster after the rebuild of in total 7 key tables. It sometimes lead to different execution plans, because the clustering factor of certain index became much more interesting. It was mainly after this action that the entire system constantly stayed at a performance level of more than 99% screens within 3 seconds. Before that we hardly reached that 99%! And even though the ordering is not maintained, a lot of data is stable but nevertheless queried over and over again: these parts of the table more or less stay &#8216;ordered&#8217;. For some tables we will be repeating the ordering process periodically. There are other ways to maintain clustering within  table like partitioning, IOT&#8217;s, sorted hash clusters etc, but all of these do not apply to use in a Siebel OLTP application. For partitioning you need a lot of money for licenses when you have a system with 16 CPU&#8217;s as well as you have to involve Siebel support to enable partitioning in OLTP.</p>
<p>But how do you rebuild a table and pre-sort its data in an always up and running application? This is where DBMS_REDEFINITION shows up as very useful. This package, available since 9i but much more powerful in 10g, makes it possible to completely redefine tables online with a minor lock moment at the end. I have become to love this built-in package.</p>
<p>With DBMS_REDEFINITION, you can:</p>
<p>• rebuild a table because you want to reorganize (and do not want to use ALTER TABLE MOVE, which is not entirely online, especially regarding indexes that are unusable after the MOVE and need a rebuild)<br />
• alter the structure of a table: add columns, drop columns, change data types<br />
• alter its physical structure: convert a heap organized table into an IOT, convert to a partitioned table, etc<br />
• Change the order of the records in the table</p>
<p>Here is an example of the code I executed to rebuild the Siebel S_ADDR_PER table</p>
<pre>-- Check if the table can be rebuilt at all:
BEGIN
  DBMS_REDEFINITION.CAN_REDEF_TABLE('SIEBEL', 'S_ADDR_PER',
                     DBMS_REDEFINITION.CONS_USE_ROWID);
END;
/

-- Create an intermediate table with the same structure or
-- (if required, with structure changes)

CREATE TABLE "SIEBEL"."BCK_S_S_ADDR_PER"
( "ROW_ID" VARCHAR2(15 CHAR) NOT NULL ENABLE
,"CREATED" DATE DEFAULT sysdate NOT NULL ENABLE
,"CREATED_BY" VARCHAR2(15 CHAR) NOT NULL ENABLE
,"LAST_UPD" DATE DEFAULT sysdate NOT NULL ENABLE
,"LAST_UPD_BY" VARCHAR2(15 CHAR) NOT NULL ENABLE
,"DCKING_NUM" NUMBER(22,7) DEFAULT 0
,"MODIFICATION_NUM" NUMBER(10,0) DEFAULT 0 NOT NULL ENABLE
,"CONFLICT_ID" VARCHAR2(15 CHAR) DEFAULT '0' NOT NULL ENABLE
,"ADDR_NAME" VARCHAR2(100 CHAR) DEFAULT 'x' NOT NULL ENABLE,
[...]
all remaining columns exactly matching the original S_ADDR_PER table
[...]
)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "DATA_TS";

-- The actual work: start the online redefinition

DECLARE
  l_num_errors NUMBER;
BEGIN
  -- This will build a materialized view log on the table to be rebuild,
  -- to capture changes during the rebuild process
  -- it will also copy all table data initially, ordered by "orderby_cols"
  SYS.DBMS_REDEFINITION.START_REDEF_TABLE('SIEBEL', 'S_ADDR_PER', 'BCK_S_S_ADDR_PER'
  , col_mapping =&gt; null
  , options_flag =&gt; SYS.DBMS_REDEFINITION.CONS_USE_ROWID
  , orderby_cols =&gt; 'x_bu_id, country, x_brick_id, zipcode, city');
  -- Copy all triggers/indexes/privileges/optionally constraints and statistics
  SYS.DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS('SIEBEL', 'S_ADDR_PER'
  , 'BCK_S_S_ADDR_PER'
  , copy_triggers=&gt;TRUE
  , copy_constraints=&gt;FALSE
  , copy_privileges=&gt;TRUE
  , copy_indexes=&gt;dbms_redefinition.cons_orig_params
  , copy_statistics=&gt;FALSE
  , num_errors=&gt;l_num_errors);
  SYS.DBMS_REDEFINITION.SYNC_INTERIM_TABLE('SIEBEL', 'S_ADDR_PER'
                                                                  , 'BCK_S_S_ADDR_PER');
EXCEPTION
  WHEN OTHERS
  THEN
    DBMS_OUTPUT.put_line ( '# of errors while copying dependent objects: '
                                      ||l_num_errors);
  RAISE;
END;
/

BEGIN
  DBMS_STATS.gather_table_stats (ownname =&gt; 'SIEBEL',tabname =&gt; 'BCK_S_S_ADDR_PER',
  estimate_percent =&gt; NULL,degree =&gt; 5,method_opt =&gt; 'FOR ALL COLUMNS SIZE 1',
  CASCADE =&gt; TRUE );
END;
/

-- Finish the redefinition: switch the two tables, drop the materialized view log
BEGIN
  SYS.DBMS_REDEFINITION.FINISH_REDEF_TABLE('SIEBEL', 'S_ADDR_PER', 'BCK_S_S_ADDR_PER');
END;
/

-- For some reason, after redefinition, the indexes were set to NOLOGGING

ALTER INDEX SIEBEL.S_ADDR_PER_EI LOGGING;
[...]
--set all remaining indexes to LOGGING again
[...]
ALTER INDEX SIEBEL.S_ADDR_PER_F1_X LOGGING;

spool off</pre>
<p>The end result is an exact copy of S_ADDR_PER, but with &#8216;clustered&#8217; data around the columns x_bu_id, country, x_brick_id, zipcode, city. The original table has now been renamed to the intermediate table&#8217;s name, as well as its indexes, triggers and other dependent objects.</p>
<h2>Internal SQL</h2>
<p>During the execution of DBMS_REDEFINITION.START_REDEF_TABLE, an INSERT statement is executed that inserts the original table&#8217;s data into the intermediate table (with an ORDER BY in our case). In one case (the rebuild of table S_CONTACT_XM) it happened that the execution plan Oracle used to execute this INSERT AS SELECT statement used an existing index as its driving index because this index was defined on the columns to order on. Now I could not remove that index or set it to UNUSABLE, because that would be violating the &#8220;100% Online&#8221; goal of the exercise. But the difference between a FULL table scan and the use of the index as driving index was 1 versus 7 hours. So I wanted to force a FULL table scan. Now that is worth tuning, but how could I do that? I tried optimizer parameters at the session level, but could not find one that eliminated the index. Now regardless of it being my lack of knowledge or there really is no magic optimizer parameter to set here, I used a trick with an outline to force the FULL table scan.</p>
<p>A few challenges there:</p>
<p>1. The internal SQL adds a column to the intermediate table, called m_row$$ of type VARCHAR2(15) which is needed to store the Oracle ROWID value of the original table. It uses it during the SYNC_INTERIM_TABLE calls of DBMS_REDEFINITION to quickly find the records to update or delete. The internal INSERT statement inserts the ROWID into the intermediate table&#8217;s m_row$$ column. And that is where the creation of an outline on that internal statement would fail: <strong>it cannot parse that statement because the m_row$$ column does not exist yet!</strong></p>
<p>2. It is a challenge to create outlines and adding your own hints to it. I use a technique learned from colleagues to do that easily, even though it does not seem to be documented and I am in doubt if it is supported. It works perfectly however.</p>
<p>So here are the steps:</p>
<p>I temporarily add the m_row$$ column to the intermediate table myself:</p>
<pre>ALTER TABLE "SIEBEL".bck_s_contact_xm ADD m_row$$ VARCHAR2(15);</pre>
<p>And then I can create an outline:</p>
<pre>DECLARE
  bq VARCHAR2 (32767); --sql statement bad query
  gq VARCHAR2 (32767); --sql statement bad query
  outln_name_bq VARCHAR2 (30); -- Final outline name (for corrected bad query)
  outln_name_gq VARCHAR2 (30); -- Temporary outline name
BEGIN
  outln_name_bq := 'REDEF_CONTACT_XM_ORDERED'; -- Final name
  outln_name_gq := 'REDEF_CONTACT_XM_ORDERED_GD'; -- Temporary name
  bq :=
    'INSERT /*+ BYPASS_RECURSIVE_CHECK APPEND */
    INTO "SIEBEL"."BCK_S_CONTACT_XM"(M_ROW$$,"ROW_ID","CREATED",
    "CREATED_BY","LAST_UPD","LAST_UPD_BY", [...]
    SELECT "S_CONTACT_XM"."ROWID","S_CONTACT_XM"."ROW_ID",
    "S_CONTACT_XM"."CREATED",
    "S_CONTACT_XM"."CREATED_BY","S_CONTACT_XM"."LAST_UPD", [...]
    FROM "SIEBEL"."S_CONTACT_XM" "S_CONTACT_XM" ORDER BY par_row_id, type';

  gq :=
    'INSERT /*+ BYPASS_RECURSIVE_CHECK APPEND */
    INTO "SIEBEL"."BCK_S_CONTACT_XM"(M_ROW$$,"ROW_ID","CREATED",
    "CREATED_BY","LAST_UPD","LAST_UPD_BY", [...]
    SELECT <span style="color:#ff0000;">/*+ FULL(S_CONTACT_XM) */ </span>"S_CONTACT_XM"."ROWID",
   "S_CONTACT_XM"."ROW_ID", "S_CONTACT_XM"."CREATED",
    "S_CONTACT_XM"."CREATED_BY","S_CONTACT_XM"."LAST_UPD", [...]
    FROM "SIEBEL"."S_CONTACT_XM" "S_CONTACT_XM" ORDER BY par_row_id, type';

  EXECUTE IMMEDIATE 'create outline "' || outln_name_bq || '" on ' || bq;
  EXECUTE IMMEDIATE 'create outline "' || outln_name_gq || '" on ' || gq;

  -- delete the hints from the bad outline
  DELETE FROM outln.ol$hints
  WHERE ol_name = outln_name_bq;

  -- rename the good hints so they apply to the bad outline
  UPDATE outln.ol$hints
     SET ol_name = outln_name_bq
   WHERE ol_name = outln_name_gq;

  -- update count of hints on the bad outline to that of the good one
  UPDATE outln.ol$
  SET hintcount = (SELECT hintcount
                     FROM outln.ol$
                    WHERE ol_name = outln_name_gq)
  WHERE ol_name = outln_name_bq;

  COMMIT;

  EXECUTE IMMEDIATE 'drop outline "' || outln_name_gq || '"';
END;
/
 </pre>
<p>Now the outline is created, because the query <em>can</em> be parsed. And the &#8216;lucky&#8217; thing is: I can drop that m_row$$ column again without the outline becoming invalid:</p>
<pre>ALTER TABLE bck_s_contact_xm DROP COLUMN m_row$$;</pre>
<p>Now the intermediate table is in the state it should be and I can continue with the DBMS_REDEFINITION. START_REDEF_TABLE, which will add the m_row$$ column to the intermediate table again and the outline will be used during the internal INSERT statement.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/127/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=127&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2009/09/23/127/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>
	</item>
		<item>
		<title>How the optimizer may use an index for cardinality estimates without actually using it</title>
		<link>http://toinevanbeckhoven.wordpress.com/2009/05/18/how-the-optimizer-may-use-an-index-for-cardinality-estimates-without-actually-using-it/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2009/05/18/how-the-optimizer-may-use-an-index-for-cardinality-estimates-without-actually-using-it/#comments</comments>
		<pubDate>Mon, 18 May 2009 14:11:31 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[Performance and Troubleshooting]]></category>
		<category><![CDATA[correlation]]></category>
		<category><![CDATA[dynamic sampling]]></category>
		<category><![CDATA[tuning by cardinality]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=114</guid>
		<description><![CDATA[The Oracle optimizer may make usage of the existence of an index just to have better information on expected cardinality and not use it to execute a query.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=114&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I was sent a data warehouse SQL query that performed badly. It took more than an hour and timed out. It was the first time that query was run with a particular parameter. Here I will show that to solve this, I created an index to give the optimizer better information, even though it did not actually use it to execute the query.<span id="more-114"></span></p>
<p>If I can, I always try to get a feeling for the cardinality estimates the optimizer makes, inspired at first by <a title="Tuning by Cardinality Feedback" href="http://www.centrexcc.com/Tuning%20by%20Cardinality%20Feedback.ppt.pdf" target="_blank">Wolfgang Breitling</a>. The optimizer is strongly driven by expected cardinality and miscalculations, especially in the early stages of an execution plan, lead to suboptimal or even bad plans. There are several reasons for miscalculations (among those data skew and correlated predicates), for which histograms, dynamic sampling and if possible query redesigns are some solutions. Too many times I see predicates in a query that are heavily or even completely correlated. If these latter can be avoided, the better.</p>
<p>The query mentioned was also a case of predicate correlation and I want to show you that the existence of an index, even though not really used for query <strong><em>execution</em></strong>, may still give the optimizer better information.</p>
<p>This is the query:</p>
<pre>SELECT   t70910.lvl1anc_divn AS c1, SUBSTR (t70910.lvl1anc_postn, 6, 4) AS c2,
         t70910.lvl1anc_postn AS c3,
         CONCAT (CONCAT (t153459.emp_last_name, ', '),
                 t153459.emp_fst_name
                ) AS c4,
         COUNT
            (DISTINCT CASE
                WHEN t427832.accnt_con_flg = 'C'
                   THEN t427832.contact_wid
             END
            ) AS c5
    FROM wc_prod_rank_tc_a t426428 <em>/* Contact Rank OA (WC_PROD_RANK_TC_A) */</em>,
         w_source_d t163300 <em>/* Sales Cycle (W_SOURCE_D) */</em>,
         w_position_d t69295 <em>/* Position (W_POSITION_D) */</em>,
         w_position_dh t70910 <em>/* SalesForce_Area */</em>,
         w_position_d t153459 <em>/* Lvl1Position_Area (W_POSITION_D) */</em>,
         wc_per_rank_tc_a t427832
   WHERE (    t163300.row_wid = t427832.cycles_wid
          AND t70910.lvl1anc_postn_id = t153459.integration_id
          AND t69295.row_wid = t70910.row_wid
          AND t69295.row_wid = t427832.owner_postn_wid
          AND t70910.lvl1anc_divn = 'SomeValue'
          AND t163300.mktpln_name = 'SomeValue 2008'
          AND t426428.row_wid = t427832.contact_rnk_wid
          AND t427832.datasource_num_id = 10008.0
          AND t427832.accnt_con_flg = 'C'
          AND CAST (t426428.ranking AS INTEGER) &lt;&gt; 1
          AND t70910.lvl1anc_postn LIKE 'UK-1-%'
          AND (t69295.datasource_num_id IN (-1.0, 10008.0))
          AND (t163300.datasource_num_id IN (-1.0, 10008.0))
          AND (t426428.tc_cat IN ('Professional Overall', 'Unspecified'))
          AND (t426428.datasource_num_id IN (-1.0, 10008.0))
          AND t70910.lvl1anc_postn NOT LIKE '%OLD%'
         )
GROUP BY t70910.lvl1anc_postn,
         t70910.lvl1anc_divn,
         CONCAT (CONCAT (t153459.emp_last_name, ', '), t153459.emp_fst_name)
  HAVING 0 &lt;
            COUNT
               (DISTINCT CASE
                   WHEN t427832.accnt_con_flg = 'C'
                      THEN t427832.contact_wid
                END
               )
     AND 0 &lt;
            COUNT
               (DISTINCT CASE
                   WHEN t427832.accnt_con_flg = 'C'
                      THEN t427832.contact_wid
                END
               )
ORDER BY c3, c4, c1;</pre>
<p>And by examining the execution plan with the &#8220;gather_plan_statistics&#8221; hint, I noticed quite a difference between the number of records estimated (186) for the WC_PROD_RANK_TC_A materialized view access and the actual records (912).  I started with dynamic sampling levels 3 and 4 and they already made the query run in 47 seconds. And it was immediately visible that the cardinality estimate for that WC_PROD_RANK_TC_A part was now completely accurate: 912.</p>
<p>However,  for that moment, dynamic sampling was not an option: we cannot add hints, we cannot alter sessions and we cannot just set it at the system level without testing (a representative set of) all other reports. It is certainly planned to test dynamic sampling level 4 soon.</p>
<p>Here is the <em>explain</em> plan for this part of the query <em>without</em> dynamic sampling:</p>
<pre>SELECT *   FROM wc_prod_rank_tc_a t426428  
WHERE CAST (t426428.ranking AS INTEGER) &lt;&gt; 1   
  AND (t426428.tc_cat IN ('Professional Overall', 'Unspecified'))   
  AND (t426428.datasource_num_id IN (-1.0, 10008.0));
<table class="default" border="1" cellspacing="0" cellpadding="2" bgcolor="#ffffff">
<tbody>
<tr class="header" style="padding-right:2px;padding-left:2px;">
<th colspan="3" width="1258" height="17" align="left">Plan</th>
</tr>
<tr class="default">
<td class="normalborder" colspan="3" height="28" align="left"><span style="color:#000080;font-family:tahoma;"><strong></strong>ALL_ROWS </span><span style="color:#000080;font-family:ms shell dlg 2;">SELECT STATEMENT </span><span style="color:#800000;font-family:tahoma;">Cost: 4 Bytes: 24,924 Cardinality: 186 </span><span style="color:#000000;font-family:tahoma;">Time: 1 </span></td>
</tr>
<tr class="default">
<td class="noborder" height="41"> </td>
<td class="normalborder" colspan="2" height="41" align="left"><span style="color:#000080;font-family:tahoma;"><strong>2 </strong></span><span style="color:#000080;font-family:ms shell dlg 2;">PARTITION LIST INLIST </span><span style="color:#800000;font-family:tahoma;">Cost: 4 Bytes: 24,924 Cardinality: 186 </span><span style="color:#000000;font-family:tahoma;">Time: 1 Partition #: 1 Partitions accessed #KEY(INLIST)</span></td>
</tr>
<tr class="default">
<td class="noborder" height="54"> </td>
<td class="noborder"> </td>
<td class="normalborder" height="54" align="left"><span style="color:#000080;font-family:tahoma;"><strong>1 </strong>SIEBELP.WC_PROD_RANK_TC_A Filter Predicates: ("T426428"."DATASOURCE_NUM_ID"=(-1) OR "T426428"."DATASOURCE_NUM_ID"=10008.0) AND ("T426428"."TC_CAT"='Professional Overall' OR "T426428"."TC_CAT"='Unspecified') AND CAST("T426428"."RANKING" AS INTEGER)&lt;&gt;1 </span><span style="color:#ff0000;font-family:ms shell dlg 2;">MAT_VIEW ACCESS FULL </span><span style="color:#000080;font-family:ms shell dlg 2;">MAT_VIEW </span><span style="color:#800000;font-family:tahoma;">Cost: 4 Bytes: 24,924 Cardinality: <strong><span style="color:#ff0000;">186</span></strong> </span><span style="color:#000000;font-family:tahoma;">Time: 1 Partition #: 1 Partitions accessed #KEY(INLIST)</span></td>
</tr>
</tbody>
</table>
</pre>
<p>And with dynamic sampling level 4 (level 3 in this case was also enough):</p>
<pre>
<table class="default" border="1" cellspacing="0" cellpadding="2" bgcolor="#ffffff">
<tbody>
<tr class="header" style="padding-right:2px;padding-left:2px;">
<th colspan="3" width="1258" height="17" align="left">Plan</th>
</tr>
<tr class="default">
<td class="normalborder" colspan="3" height="28" align="left"><span style="color:#000080;font-family:tahoma;"><strong></strong>ALL_ROWS </span><span style="color:#000080;font-family:ms shell dlg 2;">SELECT STATEMENT </span><span style="color:#800000;font-family:tahoma;">Cost: 4 Bytes: 122,208 Cardinality: 912 </span><span style="color:#000000;font-family:tahoma;">Time: 1 </span></td>
</tr>
<tr class="default">
<td class="noborder" height="41"> </td>
<td class="normalborder" colspan="2" height="41" align="left"><span style="color:#000080;font-family:tahoma;"><strong>2 </strong></span><span style="color:#000080;font-family:ms shell dlg 2;">PARTITION LIST INLIST </span><span style="color:#800000;font-family:tahoma;">Cost: 4 Bytes: 122,208 Cardinality: 912 </span><span style="color:#000000;font-family:tahoma;">Time: 1 Partition #: 1 Partitions accessed #KEY(INLIST)</span></td>
</tr>
<tr class="default">
<td class="noborder" height="54"> </td>
<td class="noborder"> </td>
<td class="normalborder" height="54" align="left"><span style="color:#000080;font-family:tahoma;"><strong>1 </strong>SIEBELP.WC_PROD_RANK_TC_A Filter Predicates: ("T426428"."DATASOURCE_NUM_ID"=(-1) OR "T426428"."DATASOURCE_NUM_ID"=10008.0) AND ("T426428"."TC_CAT"='Professional Overall' OR "T426428"."TC_CAT"='Unspecified') AND CAST("T426428"."RANKING" AS INTEGER)&lt;&gt;1 </span><span style="color:#ff0000;font-family:ms shell dlg 2;">MAT_VIEW ACCESS FULL </span><span style="color:#000080;font-family:ms shell dlg 2;">MAT_VIEW </span><span style="color:#800000;font-family:tahoma;">Cost: 4 Bytes: 122,208 Cardinality: <strong><span style="color:#ff0000;">912</span></strong> </span><span style="color:#000000;font-family:tahoma;">Time: 1 Partition #: 1 Partitions accessed #KEY(INLIST)</span></td>
</tr>
</tbody>
</table>
</pre>
<p>So with dynamic sampling as &#8220;not an option for now&#8221;, my next plan was to create a (function based)  index on the predicates for this table:</p>
<pre>CREATE INDEX SIEBELP.TVB_WC_PROD_RANK_TC_A
ON SIEBELP.WC_PROD_RANK_TC_A (TC_CAT, CAST("RANKING" AS INTEGER), ROW_WID)  
LOCAL;</pre>
<p>And now look at that same statement&#8217;s explain plan:</p>
<table class="default" border="1" cellspacing="0" cellpadding="2" bgcolor="#ffffff">
<tbody>
<tr class="header" style="padding-right:2px;padding-left:2px;">
<th colspan="3" width="1258" height="17" align="left">Plan</th>
</tr>
<tr class="default">
<td class="normalborder" colspan="3" height="28" align="left"><span style="color:#000080;font-family:tahoma;"><strong></strong>ALL_ROWS </span><span style="color:#000080;font-family:ms shell dlg 2;">SELECT STATEMENT </span><span style="color:#800000;font-family:tahoma;">Cost: 4 Bytes: 406,422 Cardinality: 3,033 </span><span style="color:#000000;font-family:tahoma;">Time: 1 </span></td>
</tr>
<tr class="default">
<td class="noborder" height="41"> </td>
<td class="normalborder" colspan="2" height="41" align="left"><span style="color:#000080;font-family:tahoma;"><strong>2 </strong></span><span style="color:#000080;font-family:ms shell dlg 2;">PARTITION LIST INLIST </span><span style="color:#800000;font-family:tahoma;">Cost: 4 Bytes: 406,422 Cardinality: 3,033 </span><span style="color:#000000;font-family:tahoma;">Time: 1 Partition #: 1 Partitions accessed #KEY(INLIST)</span></td>
</tr>
<tr class="default">
<td class="noborder" height="54"> </td>
<td class="noborder"> </td>
<td class="normalborder" height="54" align="left"><span style="color:#000080;font-family:tahoma;"><strong>1 </strong>SIEBELP.WC_PROD_RANK_TC_A Filter Predicates: (&#8220;T426428&#8243;.&#8221;DATASOURCE_NUM_ID&#8221;=(-1) OR &#8220;T426428&#8243;.&#8221;DATASOURCE_NUM_ID&#8221;=10008.0) AND (&#8220;T426428&#8243;.&#8221;TC_CAT&#8221;=&#8217;Professional Overall&#8217; OR &#8220;T426428&#8243;.&#8221;TC_CAT&#8221;=&#8217;Unspecified&#8217;) AND CAST(&#8220;T426428&#8243;.&#8221;RANKING&#8221; AS INTEGER)&lt;&gt;1 </span><span style="color:#ff0000;font-family:ms shell dlg 2;">MAT_VIEW ACCESS FULL </span><span style="color:#000080;font-family:ms shell dlg 2;">MAT_VIEW </span><span style="color:#800000;font-family:tahoma;">Cost: 4 Bytes: 406,422 Cardinality: <strong><span style="color:#ff0000;">3,033</span></strong> </span><span style="color:#000000;font-family:tahoma;">Time: 1 Partition #: 1 Partitions accessed #KEY(INLIST)</span></td>
</tr>
</tbody>
</table>
<p>It is not entirely accurate, but estimating 3 times more rows than 5 times less was much better in this case. With the index, even though it was not used to <strong><em>execute</em></strong> the query, only to <strong><em>estimate</em></strong>  cardinality, the query returned in about 40 seconds instead of an hour.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=114&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2009/05/18/how-the-optimizer-may-use-an-index-for-cardinality-estimates-without-actually-using-it/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>
	</item>
		<item>
		<title>The trains are a nightmare, IT&#8217;s a Miracle and how little can you know&#8230;: Tanel Põder in Utrecht!</title>
		<link>http://toinevanbeckhoven.wordpress.com/2009/04/02/the-trains-are-a-nightmare-its-a-miracle-and-how-little-can-you-know/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2009/04/02/the-trains-are-a-nightmare-its-a-miracle-and-how-little-can-you-know/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 18:06:18 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[Performance and Troubleshooting]]></category>
		<category><![CDATA[Miracle Masterclass]]></category>
		<category><![CDATA[Tanel Põder]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=90</guid>
		<description><![CDATA[Today was the first day of the second Miracle Masterclass this year: Tanel Põder has come to The Netherlands!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=90&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="mceTemp">
<div class="mceTemp">
<p> </p>
<dl class="wp-caption alignright">
<dt class="wp-caption-dt"><img class="size-medium wp-image-106" title="dsc02679" src="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc02679.jpg?w=300&#038;h=225" alt="Networking and evaluations" width="300" height="225" /></dt>
<dd class="wp-caption-dd">Networking and evaluations</dd>
</dl>
</div>
</div>
<p>Today was the first day of the second <a title="Miracle Benelux" href="http://www.miraclebenelux.nl" target="_blank">Miracle</a> Masterclass this year: Tanel Põder has come to The Netherlands, saw a room filled with a lot of people (he called it the best seminar even before he started, just because of the amount of attendants) and made me feel I have an awful lot to explore yet. However, that is in fact a good thing and it made me get through the &#8220;trains nightmare&#8221; today with a smile: I had trouble in the morning since I left home far too late, had to cycle as fast as I could and jumped completely exhausted with sour legs into an already late train packed with people, so I had to stand. Good start of the day. And on the way back tonight all trains around Utrecht had trouble because of some &#8220;logistic problems&#8221;. Eventually I was not unlucky: only a half hour delay, although standing again (great thing a First class ticket to Utrecht, I could really use it <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  &#8230;NOT!). But hey, I said I went through it with a smile. Because this first seminar day was already worth the money. The more new things you hear may make you feel exhausted and even a little frustrated, but at the same time satisfied because the net pay-off is awesome, right? <span id="more-90"></span></p>
<p>Cary Millsap told me (and others) Tanel is a very clever guy who knows extremely much about Oracle internals. So I checked out his <a title="Tanel's blog" href="http://www.tanelpoder.com" target="_blank">blog </a>and I figured I should be able to get a lot out of this course so I subscribed, even though my customers have limited Unix/Linux Oracle installations. To my own amazement I was able to really understand most of it (I guess my Unix/Linux skills are not so bad). It only goes so fast. As I told Anjo (Kolk, from Miracle) at the end of the day: when I was not paying attention for a few moments (dreaming about white sandy beaches or my well going 400 metres hurdles training of yesterday evening, which may very well have contributed to some problems of staying focused all time <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ), I looked at a screen showing the results of yet another demo and wondered: &#8220;What the heck caused that result?&#8221; Many, many demo&#8217;s and Tanel switching screens faster than my split times during the 400 metres hurdles training! And I was running very well&#8230;</p>
<p>What I like in particular is the drive Tanel has to create scripts that need as little privileges and change as possible. A lot of sites just have a strong policy that you cannot create packages, types, get access to X$-views etc. I am working in a place like that at this moment where I am facing the issue that they are going to revoke Unix access from everyone not in the official IT department. And I am hired by the application team as a performance troubleshooter. It is in such places that you need tools and scripts that work with the minimum amount of effort and do not need to go through days and weeks of change approvals. I was amazed by the way Tanel emulates &#8216;loops&#8217; within a SQL statement, taking advantage of the fact that V$-views are <em>not </em>Read consistent. Check out his blog, you will find a lot of valuable scripts and tools there. And as a last comment before I hit the bed: today I really saw why most Oracle guys like Unix/Linux so much. Windows has a number of drawbacks when it comes to troubleshooting problems (and then there is that paradox: in a Operating system known as  having frequent and strange problems, would you not like to have the best tools to troubleshoot them?) </p>
<div id="attachment_102" class="wp-caption alignleft" style="width: 310px"><img class="size-medium wp-image-102" title="dsc026801" src="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc026801.jpg?w=300&#038;h=225" alt="Audience from behind" width="300" height="225" /><p class="wp-caption-text">Audience from behind</p></div>
<p>03-04-2009, update to the post:  day two ended as well. No train problems today and the advantage of that is that I can use the travel time to write an update yesterday&#8217;s post.  </p>
<div class="mceTemp">
<div class="mceTemp">It was a great day again. Lots of interesting stuff, luckily also a lot of recognition for me now, otherwise I would have been exhausted again <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . The first day we talked about the different layers in the stack and the Oracle kernel layers. We dealt with the way to approach a problem and what to do if the usual ways do not show any data (V$SESSION_WAIT, SQL*Trace, ASH). We talked about latches and mutexes (a kind of cheaper latch available in the newer versions). We have seen the usage of ps, top/prstat, pmap, ipcs, pstack, strace (all to show Oracle process activity from an OS point of view) and Tanel&#8217;s snapper script. The word &#8220;script&#8221; might have been the top contributor when it comes to words spoken these two days. There was hardly a single thing where Tanel could not say the magic words: &#8220;I hate to do things by hand, so I have a script for that&#8221;.</div>
</div>
<p> The second day was mainly about execution plans, row sources, application instrumentation and tracing beyond the SID level (at the module or client_identifier level, if your connection pool applications call some instrumentation functions to set the client identifier, the module, action and client_info). Oracle has efficient ways to set these kinds of information along with the SQL statement in one network round trip by using OCI calls. In two applications I support I am really in need with more information about the actual user issuing the database calls or using the session. In both applications (Siebel and FileNet) this is not instrumented out of the box and I need to see if we can code it in somewhere. It would be so helpful if these packaged applications would at least provide this minimum amount of instrumentation. </p>
<div id="attachment_104" class="wp-caption alignleft" style="width: 310px"><img class="size-medium wp-image-104 " title="dsc026781" src="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc026781.jpg?w=300&#038;h=225" alt="Tanel in discussion" width="300" height="225" /><p class="wp-caption-text">Tanel in discussion</p></div>
<p> Also interesting was the topic on the life cycle of a cursor and why SQL cannot always be shared, even though the SQL text is similar. Since this topic touched the SQL Hash value and SQL_ID I raised the question if you can generate the SQL_ID or hash value when you know the SQL statement. In other words: is the function that generates the hash value and the SQL_ID available to us? Tanel and Anjo discussed some things about this, but we came to the conclusion that this hashing algorithm (and SQL_ID algorithm) is not publicly available. Anyone knows whether it probably is? I would love it, since we use a great tool written by one smart guy at our customer to display performance characteristics of Siebel applications (parsing Siebel log files) and the SQL stored in there I would love to match with SQL I see in V$SQL&#8230;but to search on the SQL_TEXT is both slow and cumbersome (especially with the long Siebel queries which are a lot of the time very similar, but slightly different).</p>
<p>The seminar was a big success: a very technical one presented by indeed (Cary was right) very smart guy. I like Oracle internals and if you like it too, go and see Tanel Põder&#8217;s seminar and read his blog. You have to have a solid background in Oracle otherwise it might be very frustrating. And some Unix/Linux knowledge is important!</p>
<p>Thanks Tanel, for two great days (and thanks Anjo and Annette as well for giving the opportunity)! See you next time!</p>
<div class="mceTemp"> </div>
<div class="mceTemp">Some more pictures below:</div>

<a href='http://toinevanbeckhoven.wordpress.com/2009/04/02/the-trains-are-a-nightmare-its-a-miracle-and-how-little-can-you-know/dsc026801/' title='dsc026801'><img data-attachment-id='102' data-orig-size='816,612' data-liked='0'width="150" height="112" src="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc026801.jpg?w=150&#038;h=112" class="attachment-thumbnail" alt="Audience from behind" title="dsc026801" /></a>
<a href='http://toinevanbeckhoven.wordpress.com/2009/04/02/the-trains-are-a-nightmare-its-a-miracle-and-how-little-can-you-know/dsc026781/' title='dsc026781'><img data-attachment-id='104' data-orig-size='816,612' data-liked='0'width="150" height="112" src="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc026781.jpg?w=150&#038;h=112" class="attachment-thumbnail" alt="Tanel in discussion" title="dsc026781" /></a>
<a href='http://toinevanbeckhoven.wordpress.com/2009/04/02/the-trains-are-a-nightmare-its-a-miracle-and-how-little-can-you-know/dsc02679/' title='dsc02679'><img data-attachment-id='106' data-orig-size='1632,1224' data-liked='0'width="150" height="112" src="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc02679.jpg?w=150&#038;h=112" class="attachment-thumbnail" alt="Networking and evaluations" title="dsc02679" /></a>
<a href='http://toinevanbeckhoven.wordpress.com/2009/04/02/the-trains-are-a-nightmare-its-a-miracle-and-how-little-can-you-know/dsc02683/' title='dsc02683'><img data-attachment-id='107' data-orig-size='816,612' data-liked='0'width="150" height="112" src="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc02683.jpg?w=150&#038;h=112" class="attachment-thumbnail" alt="Presenter and Organizor" title="dsc02683" /></a>
<a href='http://toinevanbeckhoven.wordpress.com/2009/04/02/the-trains-are-a-nightmare-its-a-miracle-and-how-little-can-you-know/dsc02676/' title='dsc02676'><img data-attachment-id='108' data-orig-size='816,612' data-liked='0'width="150" height="112" src="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc02676.jpg?w=150&#038;h=112" class="attachment-thumbnail" alt="Very good cookies" title="dsc02676" /></a>

<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=90&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2009/04/02/the-trains-are-a-nightmare-its-a-miracle-and-how-little-can-you-know/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>

		<media:content url="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc02679.jpg?w=300" medium="image">
			<media:title type="html">dsc02679</media:title>
		</media:content>

		<media:content url="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc026801.jpg?w=300" medium="image">
			<media:title type="html">dsc026801</media:title>
		</media:content>

		<media:content url="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc026781.jpg?w=300" medium="image">
			<media:title type="html">dsc026781</media:title>
		</media:content>

		<media:content url="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc026801.jpg?w=150" medium="image">
			<media:title type="html">dsc026801</media:title>
		</media:content>

		<media:content url="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc026781.jpg?w=150" medium="image">
			<media:title type="html">dsc026781</media:title>
		</media:content>

		<media:content url="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc02679.jpg?w=150" medium="image">
			<media:title type="html">dsc02679</media:title>
		</media:content>

		<media:content url="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc02683.jpg?w=150" medium="image">
			<media:title type="html">dsc02683</media:title>
		</media:content>

		<media:content url="http://toinevanbeckhoven.files.wordpress.com/2009/04/dsc02676.jpg?w=150" medium="image">
			<media:title type="html">dsc02676</media:title>
		</media:content>
	</item>
		<item>
		<title>Index statistics on complete refreshed materialized views. What is going on?</title>
		<link>http://toinevanbeckhoven.wordpress.com/2009/03/14/index-statistics-on-complete-refreshed-materialized-views-what-is-going-on/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2009/03/14/index-statistics-on-complete-refreshed-materialized-views-what-is-going-on/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 20:28:18 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[Performance and Troubleshooting]]></category>
		<category><![CDATA[SQL and PL/SQL]]></category>
		<category><![CDATA[ETL]]></category>
		<category><![CDATA[index statistics]]></category>
		<category><![CDATA[materialized views]]></category>
		<category><![CDATA[Oracle 10.2.0.4]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=77</guid>
		<description><![CDATA[A few days ago I discovered some (to my feeling) buggy behavior during a COMPLETE refresh of a -partitioned- materialized view. It was an unfortunate situation, because it was discovered the day after going into production. It was not noticed during the weeks of development and pre-production execution. Seems like we have some improvement to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=77&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few days ago I discovered some (to my feeling) buggy behavior during a COMPLETE refresh of a -partitioned- materialized view. It was an unfortunate situation, because it was discovered the day after going into production. It was not noticed during the weeks of development and pre-production execution. Seems like we have some improvement to do there. It had to do with the index statistics on GLOBAL indexes of a partitioned materialized view. The first time our ETL ran with some new materialized views implemented on them, the ETL did its job and COMPLETE refreshed a  new MV. So far, so good, that was the intention. However, countries started complaining about huge performance problems with some specific reports and another ETL part (only run on Production, which is one of those things I did not know and we need to improve a next time we test a new implementation) was taking hours and hours where it normally would take a few minutes. <span id="more-77"></span></p>
<h2>First discovery</h2>
<p>We soon found out the ETL and reports problems all had to do with this new materialized view, which was an &#8216;exact&#8217; replacement of a manually refreshed aggregate table with the exact same indexes and columns. The statistics had also been gathered on the MV. I looked at the execution plans of the badly behaving ETL first and saw that Oracle was using a GLOBAL index defined on the new MV. The cardinality estimates in the execution plan were 1, however, the number of records to be retrieved were in the millions. So it had to be  a statistic issue. I checked and saw that all the indexes were last analyzed somewhere during the normal ETL and to be exact: they were analyzed as part of the COMPLETE refresh. At first I wondered: who did an analyze of that table&#8217;s indexes during the ETL, is it defined in the ETL somewhere? It took me a few moments to realize that the way we do the COMPLETE refresh is a so called &#8216;non-atomic&#8217; one:</p>
<pre>begin
  dbms_mview.REFRESH('SOME_JOIN_MV','COMPLETE',<strong><span style="color:#ff0000;">atomic_refresh</span>=&gt;</strong>FALSE);
end;
/</pre>
<p>This effectively does a COMPLETE refresh by doing a TRUNCATE, followed by a direct path insert and an efficient rebuild of all the indexes. And it was this rebuild of the indexes that lead to the analyze of those indexes: Oracle 10g and above automatically (re-)analyzes the new or rebuilt indexes on a table when this table already has statistics gathered. So OK, I found out where the analyze came from. But why was the cardinality so wrong? I checked and to my surprise the num_rows statistic was set to zero (not NULL) for the GLOBAL indexes only. The partitioned indexes however where analyzed fine: their statistics were accurate. So I went testing this behavior (after first correcting the statistics on those indexes in Production to have performance return to normal) and I saw what Oracle did (among others by taking a SQLtrace during the COMPLETE refresh). And this was the situation on HP-UX Oracle 10.2.0.4 64bit:</p>
<ol>
<li>Oracle did a TRUNCATE of the MV</li>
<li>Oracle set the indexes to unusable <span style="color:#ff0000;">AND set the statistics of the GLOBAL indexes to zero</span>!</li>
<li>Oracle did the Direct Path Insert</li>
<li>Oracle rebuilt the indexes &#8211;&gt; automatic analyze of the LOCAL partitioned indexes, but not of the GLOBAL ones</li>
</ol>
<p>So after the refresh the statistics on the GLOBAL indexes were zero and the LAST ANALYZE was from the moment after the TRUNCATE, but the LOCAL indexes statistics were fine: they seemed to have gathered normally during the rebuild. To me that sounds like a bug. I cannot explain why this behavior would be like that. And that was the cause of the performance problems: with index statistics set to zero, Oracle considered these GLOBAL indexes as extremely cheap and used them in about every query. But that was completely misleading information. I adjusted the materialized view refresh stored procedure by adding an explicit dbms_stats.gather_index_stats on those GLOBAL indexes and everything went back to normal.</p>
<h2>But then&#8230;</h2>
<p> &#8230;I wanted to wrote this post and started retesting this on my Windows XP 64bit 10.2.0.4. The same version (I may be off by a minor patchlevel, I need to check) and the same kind of MV (not the same one, but also a join MV). To my surprise during test Oracle did a good job at the COMPLETE refresh for the GLOBAL indexes: now these were gathered also and to be most specific: as one of the last steps of the refresh. Seems like the thing that was forgotten on the HP-UX version. But now another thing seems wrong: the TABLE level statistics of the LOCAL partitioned indexes are not gathered. The example I prepared was:</p>
<pre>DROP TABLE some_fact;
DROP TABLE some_domain;

CREATE TABLE some_fact AS SELECT * FROM all_objects;
CREATE TABLE some_domain AS SELECT * FROM all_tables;

CREATE UNIQUE INDEX pk_some_domain ON some_domain (owner,table_name);

CREATE MATERIALIZED VIEW some_join_mv
PARTITION BY LIST (object_type)
(   PARTITION part_table VALUES ('TABLE'),  
    PARTITION part_index VALUES ('INDEX'),  
    PARTITION part_proc VALUES ('PROCEDURE','PACKAGE','FUNCTION'),  
    PARTITION part_remaining VALUES (DEFAULT))
BUILD IMMEDIATE REFRESH
COMPLETE ON DEMAND AS
SELECT f.object_name
     , f.object_type
     , f.owner
     , f.status
     , f.last_ddl_time
     , d.avg_row_len
     , d.blocks
     , d.empty_blocks
     , d.partitioned
     , d.tablespace_name
  FROM some_fact f, some_domain d
 WHERE f.object_name = d.table_name(+) AND f.owner = d.owner(+);

BEGIN
   DBMS_STATS.gather_table_stats (ownname               =&gt; USER
                                , tabname               =&gt; 'SOME_JOIN_MV'
                                , estimate_percent      =&gt; 100
                                , granularity           =&gt; 'ALL'
                                , method_opt            =&gt; 'FOR ALL COLUMNS SIZE 1'
                                , CASCADE               =&gt; TRUE
                                 );
END;
/

CREATE  INDEX idx_some_join_mv_p1 ON some_join_mv (object_name, object_type, owner) <span style="color:#ff0000;">GLOBAL</span>;
CREATE  INDEX idx_some_join_mv_type_local ON some_join_mv (object_type) <span style="color:#ff0000;">LOCAL</span>;

SELECT   index_name
       , table_name
       , partition_name
       , leaf_blocks
       , distinct_keys
       , clustering_factor
       , num_rows
       , last_analyzed
    FROM all_ind_statistics
   WHERE table_name = 'SOME_JOIN_MV'
ORDER BY index_name, partition_name NULLS FIRST;</pre>
<p>Results were (the TABLE level statistics of the LOCAL partitioned index in <span style="color:#ff0000;">Red</span>):</p>
<table border="1" cellspacing="1" cellpadding="1" width="100%">
<tbody>
<tr>
<th align="left">index_name</th>
<th align="left">table_name</th>
<th align="left">partition_name</th>
<th align="left">leaf_blocks</th>
<th align="left">distinct_keys</th>
<th align="left">clustering_factor</th>
<th align="left">num_rows</th>
<th align="left">last_analyzed</th>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_P1</td>
<td>SOME_JOIN_MV</td>
<td> </td>
<td>589</td>
<td>50675</td>
<td>23994</td>
<td>77427</td>
<td>14-3-2009 21:13:36</td>
</tr>
<tr>
<td><span style="color:#ff0000;">IDX_SOME_JOIN_MV_TYPE_LOCAL</span></td>
<td><span style="color:#ff0000;">SOME_JOIN_MV</span></td>
<td><span style="color:#ff0000;"> </span></td>
<td><span style="color:#ff0000;">242</span></td>
<td><span style="color:#ff0000;">29</span></td>
<td><span style="color:#ff0000;">1061</span></td>
<td><span style="color:#ff0000;">77427</span></td>
<td><span style="color:#ff0000;">14-3-2009 21:13:36</span></td>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_TYPE_LOCAL</td>
<td>SOME_JOIN_MV</td>
<td>PART_INDEX</td>
<td>7</td>
<td>1</td>
<td>20</td>
<td>2804</td>
<td>14-3-2009 21:13:36</td>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_TYPE_LOCAL</td>
<td>SOME_JOIN_MV</td>
<td>PART_PROC</td>
<td>4</td>
<td>3</td>
<td>27</td>
<td>1234</td>
<td>14-3-2009 21:13:36</td>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_TYPE_LOCAL</td>
<td>SOME_JOIN_MV</td>
<td>PART_REMAINING</td>
<td>218</td>
<td>24</td>
<td>971</td>
<td>68115</td>
<td>14-3-2009 21:13:36</td>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_TYPE_LOCAL</td>
<td>SOME_JOIN_MV</td>
<td>PART_TABLE</td>
<td>13</td>
<td>1</td>
<td>43</td>
<td>5274</td>
<td>14-3-2009 21:13:36</td>
</tr>
</tbody>
</table>
<p>Then I deleted almost all records in the Fact table, did a COMPLETE refresh and see what the index statistics were after that:</p>
<pre>DELETE FROM some_fact
      WHERE ROWNUM &lt;= 77000;
COMMIT ;

BEGIN
   dbms_mview.REFRESH ('SOME_JOIN_MV', 'COMPLETE', atomic_refresh =&gt; FALSE);
END;
/</pre>
<p>See the inaccuracy:</p>
<table border="1" cellspacing="1" cellpadding="1" width="100%">
<tbody>
<tr>
<th align="left">index_name</th>
<th align="left">table_name</th>
<th align="left">partition_name</th>
<th align="left">leaf_blocks</th>
<th align="left">distinct_keys</th>
<th align="left">clustering_factor</th>
<th align="left">num_rows</th>
<th align="left">last_analyzed</th>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_P1</td>
<td>SOME_JOIN_MV</td>
<td> </td>
<td>3</td>
<td>421</td>
<td>18</td>
<td>427</td>
<td>14-3-2009 21:20:50</td>
</tr>
<tr>
<td><span style="color:#ff0000;">IDX_SOME_JOIN_MV_TYPE_LOCAL</span></td>
<td><span style="color:#ff0000;">SOME_JOIN_MV</span></td>
<td><span style="color:#ff0000;"> </span></td>
<td><span style="color:#ff0000;">242</span></td>
<td><span style="color:#ff0000;">29</span></td>
<td><span style="color:#ff0000;">1061</span></td>
<td><span style="color:#ff0000;">77427</span></td>
<td><span style="color:#ff0000;">14-3-2009 21:13:36</span></td>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_TYPE_LOCAL</td>
<td>SOME_JOIN_MV</td>
<td>PART_INDEX</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>2</td>
<td>14-3-2009 21:20:50</td>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_TYPE_LOCAL</td>
<td>SOME_JOIN_MV</td>
<td>PART_PROC</td>
<td>1</td>
<td>3</td>
<td>1</td>
<td>8</td>
<td>14-3-2009 21:20:50</td>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_TYPE_LOCAL</td>
<td>SOME_JOIN_MV</td>
<td>PART_REMAINING</td>
<td>1</td>
<td>4</td>
<td>1</td>
<td>18</td>
<td>14-3-2009 21:20:50</td>
</tr>
<tr>
<td>IDX_SOME_JOIN_MV_TYPE_LOCAL</td>
<td>SOME_JOIN_MV</td>
<td>PART_TABLE</td>
<td>1</td>
<td>1</td>
<td>4</td>
<td>399</td>
<td>14-3-2009 21:20:50</td>
</tr>
</tbody>
</table>
<p>All indexes have accurate statistics, but the TABLE level statistics on IDX_SOME_JOIN_MV_TYPE_LOCAL are still the old ones.</p>
<p>So I witnessed two strange things in INDEX statistics with COMPLETE refreshed materialized views. Can anyone tell me the reasons&#8230;? At least I learned to pay carefull attention to the statistics when dealing with materialized views refreshes, that is for sure!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=77&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2009/03/14/index-statistics-on-complete-refreshed-materialized-views-what-is-going-on/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle 11 upgrade challenges</title>
		<link>http://toinevanbeckhoven.wordpress.com/2009/02/26/oracle-11-upgrade-challenges/</link>
		<comments>http://toinevanbeckhoven.wordpress.com/2009/02/26/oracle-11-upgrade-challenges/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 22:08:12 +0000</pubDate>
		<dc:creator>tvbeckho</dc:creator>
				<category><![CDATA[SQL and PL/SQL]]></category>
		<category><![CDATA[default value]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[PLS-00593]]></category>
		<category><![CDATA[PLS-00801]]></category>
		<category><![CDATA[upgrade 11g]]></category>

		<guid isPermaLink="false">http://toinevanbeckhoven.wordpress.com/?p=64</guid>
		<description><![CDATA[PLS-00593: default value of parameter &#8220;x&#8221; must match that of spec At one customer, we are upgrading from Oracle 8.1.7.4 to Oracle 11g. It was about time. So far, there are not many challenges. The few problems so far have to do with migrating from a Single Byte character set to a Multibyte character set [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=64&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2><span style="color:#000000;">PLS-00593: default value of parameter &#8220;x&#8221; must match that of spec</span></h2>
<p>At one customer, we are upgrading from Oracle 8.1.7.4 to Oracle 11g. It was about time. So far, there are not many challenges. The few problems so far have to do with migrating from a Single Byte character set to a Multibyte character set (on purpose) and some PL/SQL mismatches. Today I was looking into some package bodies that did not compile in 11g. The error was a <span style="color:#ff0000;">PLS-00593: default value of parameter &#8220;x&#8221; must match that of spec<span style="color:#000000;">.  So we seemed to have a few packages with one or more functions in them in which the parameter default values did not match. So I had to straighten that and I wondered: what is the one it must be if I do not want the risk of changing the application logic that may rely on the default values. The one in the specification, or the one in the body? <span id="more-64"></span>The best way to answer that question is to test it:</span></span></p>
<pre><span style="font-size:x-small;color:#0000ff;font-family:Courier;">CREATE OR</span><span style="font-size:xx-small;font-family:Times New Roman;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">REPLACE</span><span style="font-size:xx-small;font-family:Times New Roman;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">PACKAGE</span><span style="font-size:xx-small;font-family:Times New Roman;"> </span><span style="font-size:x-small;font-family:Courier;">par_test</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">
IS</span>
<span style="font-size:x-small;color:#0000ff;font-family:Courier;">  PROCEDURE</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;font-family:Courier;">test_par</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">(a</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">IN</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#ff0000;font-family:Courier;">VARCHAR2</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">,</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;font-family:Courier;">b</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">IN</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#ff0000;font-family:Courier;">VARCHAR2</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">DEFAULT</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#ff0000;font-family:Courier;"><strong>'TRUE'</strong></span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">);
END;
/</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;"> 
<span style="font-size:x-small;color:#0000ff;font-family:Courier;">
CREATE</span></span><span style="font-size:xx-small;font-family:Times New Roman;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">OR</span><span style="font-size:xx-small;font-family:Times New Roman;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">REPLACE</span><span style="font-size:xx-small;font-family:Times New Roman;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">PACKAGE</span><span style="font-size:xx-small;font-family:Times New Roman;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">BODY</span><span style="font-size:xx-small;font-family:Times New Roman;"> </span><span style="font-size:x-small;font-family:Courier;">par_test</span>
<span style="font-size:x-small;color:#0000ff;font-family:Courier;">IS
</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">  PROCEDURE</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;font-family:Courier;">test_par</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">(a</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">IN</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#ff0000;font-family:Courier;">VARCHAR2</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">,</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;font-family:Courier;">b</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">IN</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#ff0000;font-family:Courier;">VARCHAR2</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">DEFAULT</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#ff0000;font-family:Courier;"><strong>'FALSE'</strong></span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">)</span>
<span style="font-size:x-small;color:#0000ff;font-family:Courier;">  IS</span>
<span style="font-size:x-small;color:#0000ff;font-family:Courier;">  BEGIN</span>
<strong><em><span style="font-size:x-small;font-family:Courier;">   DBMS_OUTPUT.put_line</span></em><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">(</span><span style="font-size:x-small;color:#ff0000;font-family:Courier;">'b='</span><span style="font-size:xx-small;"> || </span><span style="font-size:x-small;font-family:Courier;">b</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">);</span></strong>
<span style="font-size:x-small;color:#0000ff;font-family:Courier;">  END;
END;
/
</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">
BEGIN
</span><span style="font-size:x-small;font-family:Courier;">  par_test</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">.</span><span style="font-size:x-small;font-family:Courier;">test_par</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">(</span><span style="font-size:x-small;color:#ff0000;font-family:Courier;">'And the answer is...'</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">,</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#ff0000;font-family:Courier;">'UNKNOWN'</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">); -- specify a value for parameter b</span>
<span style="font-size:x-small;font-family:Courier;">  par_test</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">.</span><span style="font-size:x-small;font-family:Courier;">test_par</span><span style="font-size:xx-small;"> </span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">(</span><span style="font-size:x-small;color:#ff0000;font-family:Courier;">'And the answer is...'</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">); -- rely on default value
END;
/
</span><span style="font-size:x-small;font-family:Courier;">
Result:
<span style="font-size:x-small;font-family:Courier;">b</span></span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">=</span><span style="font-size:x-small;font-family:Courier;">UNKNOWN<span style="font-size:x-small;font-family:Courier;">
b</span></span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">=TRUE</span></pre>
<p>So it seems to be the default value of the package specification that rules&#8230;</p>
<h2>PLS-00801: internal error [phd_get_defn: unexpected overloaded D_S_ED]</h2>
<p>One other error that came along was in one other package body. I got the scary looking <span style="color:#ff0000;">PLS-00801: internal error [phd_get_defn: unexpected overloaded D_S_ED]<span style="color:#000000;">. There was not much to be found on the Internet, except that you need to contact Oracle support if you get it. I like to check if I can isolate the cause for it first and then probably solve it.</span></span></p>
<p><span style="color:#ff0000;"><span style="color:#000000;">The package body consists of a lot of generated code, generated by <a title="PL/Generator" href="http://www.stevenfeuerstein.com/puter/gencentral.htm#plgen" target="_blank">PL/Generator</a> (a PL/SQL generator I have used with lots of joy. It is created by Steven Feuerstein and has an even much more powerful successor called the <a title="Quest CodeGen Utility" href="http://www.qcgu.net/index.php" target="_blank">Quest CodeGen Utility</a> now). Since almost all the packages in the schema contained similar generated code, I had a feeling the error must be caused by my own customized code. So I commented out the custom procedures/functions in the specification and tried to compile both spec and body. That already compiled fine. So I started to un-comment the custom modules one by one and very soon I found that the error was caused by calls to </span></span></p>
<pre><span style="color:#ff0000;"><span style="color:#000000;"><span style="font-size:x-small;color:#0000ff;font-family:Courier;">PRAGMA RESTRICT_REFERENCES(</span><span style="font-size:x-small;font-family:Courier;">code_convert_to</span><span style="font-size:x-small;color:#0000ff;font-family:Courier;">,WNDS,WNPS);</span></span></span></pre>
<p> <span style="color:#ff0000;"><span style="color:#000000;">These packages were created in the years of Oracle 7 and back then it was a lot of times necessary to &#8220;tell&#8221; Oracle that a function adhered to certain rules, like that it did not changed package state or database state, in order to use it in regular SQL statements. As years went by, the compiler got more intelligent and Oracle could find out a lot of these things itself. I did not expect that I would get a nasty PL/SQL error on the remains of this &#8220;Oracle 7&#8243; code once&#8230; Well, it may be of use to anyone who gets this same error, since Google and MetaLink did not help me here.<span style="font-size:x-small;color:#0000ff;font-family:Courier;"><span style="font-size:x-small;color:#0000ff;font-family:Courier;"> </span></span></span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/toinevanbeckhoven.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/toinevanbeckhoven.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/toinevanbeckhoven.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/toinevanbeckhoven.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/toinevanbeckhoven.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/toinevanbeckhoven.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/toinevanbeckhoven.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/toinevanbeckhoven.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/toinevanbeckhoven.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/toinevanbeckhoven.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/toinevanbeckhoven.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/toinevanbeckhoven.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/toinevanbeckhoven.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/toinevanbeckhoven.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=toinevanbeckhoven.wordpress.com&amp;blog=6354425&amp;post=64&amp;subd=toinevanbeckhoven&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://toinevanbeckhoven.wordpress.com/2009/02/26/oracle-11-upgrade-challenges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">tvbeckho</media:title>
		</media:content>
	</item>
	</channel>
</rss>
