<?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>DBA Sensation</title>
	<atom:link href="http://zhefeng.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://zhefeng.wordpress.com</link>
	<description>Just another boring DBA notes</description>
	<lastBuildDate>Thu, 05 Jan 2012 01:31:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='zhefeng.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/75d487d33b2e11653658a6c4334b5460?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>DBA Sensation</title>
		<link>http://zhefeng.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://zhefeng.wordpress.com/osd.xml" title="DBA Sensation" />
	<atom:link rel='hub' href='http://zhefeng.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to configure resource governor in sql 2008 to seperate the classified work load</title>
		<link>http://zhefeng.wordpress.com/2012/01/04/how-to-configure-resource-governor-in-sql-2008-to-seperate-the-classified-work-load/</link>
		<comments>http://zhefeng.wordpress.com/2012/01/04/how-to-configure-resource-governor-in-sql-2008-to-seperate-the-classified-work-load/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 01:30:09 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[3. MS SQL Server]]></category>
		<category><![CDATA[resource control]]></category>
		<category><![CDATA[resource governor]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[work load]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=203</guid>
		<description><![CDATA[On our server some big apps always eat up all resource which cause other apps get hang as well. Try to seperate the traffic between big apps and normal apps on a shared sql instance by implementing resource governor. Here is the plan for pools. pBigApp takes maxium 60% resource and other apps by default [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=203&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On our server some big apps always eat up all resource which cause other apps get hang as well.<br />
Try to seperate the traffic between big apps and normal apps on a shared sql instance by implementing resource governor.</p>
<p>Here is the plan for pools. pBigApp takes maxium 60% resource and other apps by default using default pool.</p>
<p>Pool_name	MIN%	MAX%	Calculated_Effective_Max%	Calculated_Shared%	Comment<br />
internal	0	100	100				0			not applicable to internal pool<br />
default		0	100	100				100			Calculated_Effective_Max%= min(MAX%,100-sum(min%)), calculated_shared%= Calculated_Effective_Max% &#8211; Min%<br />
pBigapp		0	60	60				60</p>
<p>Configuration:<br />
1. make sure the resource governor is enabled<br />
select is_enabled from sys.resource_governor_configuration<br />
&#8211;if it returns &#8220;0&#8243;, then you need to enable it<br />
ALTER RESOURCE GOVERNOR RECONFIGURE;</p>
<p>2. Issue a CREATE RESOURCE POOL statement to create a resource pool<br />
USE master;<br />
&#8211; Create a resource pool &#8220;pBigApp&#8221; that sets the MAX_CPU_PERCENT to 60%.<br />
CREATE RESOURCE POOL pBigApp WITH (MAX_CPU_PERCENT = 60);<br />
GO</p>
<p>3. Create a workload group to use new pool &#8220;pBigApp&#8221;<br />
CREATE WORKLOAD GROUP gASTEC USING pBigApp;<br />
GO</p>
<p>4. Create a classifier function that maps the workload group created in the preceding step to the user of the low-priority login<br />
&#8211;Note that any request that does not get classified goes into the &#8216;Default&#8217; group.<br />
USE master;<br />
CREATE FUNCTION dbo.rgclassifier_MAX_CPU() RETURNS sysname<br />
WITH SCHEMABINDING<br />
AS<br />
BEGIN<br />
    DECLARE @workload_group_name AS sysname<br />
      IF (SUSER_NAME() = &#8216;ASTEC&#8217;)<br />
          SET @workload_group_name = &#8216;gASTEC&#8217;<br />
    RETURN @workload_group_name<br />
END;<br />
GO</p>
<p>&#8211;another function example with application name classfied<br />
CREATE FUNCTION dbo.rgclassifier_v1() RETURNS sysname<br />
WITH SCHEMABINDING<br />
AS<br />
BEGIN<br />
    DECLARE @grp_name sysname<br />
      IF (SUSER_NAME() = &#8216;sa&#8217;)<br />
          SET @grp_name = &#8216;GroupAdmin&#8217;<br />
      IF (APP_NAME() LIKE &#8216;%MANAGEMENT STUDIO%&#8217;)<br />
          OR (APP_NAME() LIKE &#8216;%QUERY ANALYZER%&#8217;)<br />
          SET @grp_name = &#8216;GroupAdhoc&#8217;<br />
      IF (APP_NAME() LIKE &#8216;%REPORT SERVER%&#8217;)<br />
          SET @grp_name = &#8216;GroupReports&#8217;<br />
    RETURN @grp_name<br />
END;<br />
GO</p>
<p>5. Register the classifier function with Resource Governor.<br />
ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION= dbo.rgclassifier_MAX_CPU);</p>
<p>6. Verify the classification of specific sessions<br />
log in as the user that you specified in your classifier function, and verify the session classification by issuing the following SELECT statement<br />
USE master;<br />
SELECT sess.session_id, sess.login_name, sess.group_id, grps.name<br />
FROM sys.dm_exec_sessions AS sess<br />
JOIN sys.dm_resource_governor_workload_groups AS grps<br />
    ON sess.group_id = grps.group_id<br />
WHERE session_id &gt; 50;<br />
GO</p>
<p>Useful scripts:<br />
1. what workload group and resource pool in Resource Governor was assigned to each session<br />
SELECT    session_id as &#8216;Session ID&#8217;,<br />
              [host_name] as &#8216;Host Name&#8217;,<br />
              [program_name] as &#8216;Program Name&#8217;,<br />
              nt_user_name as &#8216;User Name&#8217;,<br />
              SDRGWG.[Name] as &#8216;Group Assigned&#8217;,<br />
              DRGRP.[name] as &#8216;Pool Assigned&#8217;<br />
FROM sys.dm_exec_sessions SDES<br />
        INNER JOIN sys.dm_resource_governor_workload_groups SDRGWG<br />
                ON SDES.group_id = SDRGWG.group_id<br />
        INNER JOIN sys.dm_resource_governor_resource_pools DRGRP<br />
                ON SDRGWG.pool_id = DRGRP.pool_id</p>
<p>2. Assigns all new sessions to the default workload group by removing any existing classifier function from the Resource Governor configuration.<br />
ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION = NULL);<br />
GO<br />
ALTER RESOURCE GOVERNOR RECONFIGURE;</p>
<p>3.Example of store the classifier function in the master database.<br />
USE master;<br />
GO<br />
SET ANSI_NULLS ON;<br />
GO<br />
SET QUOTED_IDENTIFIER ON;<br />
GO<br />
CREATE FUNCTION dbo.rgclassifier_v1() RETURNS sysname<br />
WITH SCHEMABINDING<br />
AS<br />
BEGIN<br />
&#8211; Declare the variable to hold the value returned in sysname.<br />
    DECLARE @grp_name AS sysname<br />
&#8211; If the user login is &#8216;sa&#8217;, map the connection to the groupAdmin<br />
&#8211; workload group.<br />
    IF (SUSER_NAME() = &#8216;sa&#8217;)<br />
        SET @grp_name = &#8216;groupAdmin&#8217;<br />
&#8211; Use application information to map the connection to the groupAdhoc<br />
&#8211; workload group.<br />
    ELSE IF (APP_NAME() LIKE &#8216;%MANAGEMENT STUDIO%&#8217;)<br />
        OR (APP_NAME() LIKE &#8216;%QUERY ANALYZER%&#8217;)<br />
            SET @grp_name = &#8216;groupAdhoc&#8217;<br />
&#8211; If the application is for reporting, map the connection to<br />
&#8211; the groupReports workload group.<br />
    ELSE IF (APP_NAME() LIKE &#8216;%REPORT SERVER%&#8217;)<br />
        SET @grp_name = &#8216;groupReports&#8217;<br />
&#8211; If the connection does not map to any of the previous groups,<br />
&#8211; put the connection into the default workload group.<br />
    ELSE<br />
        SET @grp_name = &#8216;default&#8217;<br />
    RETURN @grp_name<br />
END<br />
GO<br />
&#8211; Register the classifier user-defined function and update the<br />
&#8211; the in-memory configuration.<br />
ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION=dbo.rgclassifier_v1);<br />
GO<br />
ALTER RESOURCE GOVERNOR RECONFIGURE;<br />
GO</p>
<p>4. system views and dm views<br />
sys.resource_governor_configuration:  Returns the stored Resource Governor state.<br />
sys.resource_governor_resource_pools: Returns the stored resource pool configuration. Each row of the view determines the configuration of a pool.<br />
sys.resource_governor_workload_groups: Returns the stored workload group configuration.</p>
<p>sys.dm_resource_governor_workload_groups: Returns workload group statistics and the current in-memory configuration of the workload group.<br />
sys.dm_resource_governor_resource_pools: Returns information about the current resource pool state, the current configuration of resource pools, and resource pool statistics.<br />
sys.dm_resource_governor_configuration: Returns a row that contains the current in-memory configuration state for Resource Governor.</p>
<p>Reference:<br />
1. Managing SQL Server Workloads with Resource Governor</p>
<p>http://msdn.microsoft.com/en-us/library/bb933866.aspx</p>
<p>2. Part 1: Anatomy of SQL Server 2008 Resource Governor CPU Demo</p>
<p>http://blogs.technet.com/b/sqlos/archive/2007/12/14/part-1-anatomy-of-sql-server-2008-resource-governor-cpu-demo.aspx</p>
<p>3. Part 2: Resource Governor CPU Demo on multiple CPUs</p>
<p>http://blogs.technet.com/b/sqlos/archive/2008/01/18/part-2-resource-governor-cpu-demo-on-multiple-cpus.aspx</p>
<p>4. How to: Use Resource Governor to Limit CPU Usage by Backup Compression (Transact-SQL)</p>
<p>http://msdn.microsoft.com/en-us/library/cc280384.aspx</p>
<p>5. Resource Governor DDL and System Views</p>
<p>http://msdn.microsoft.com/en-us/library/bb895339.aspx</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/203/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=203&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2012/01/04/how-to-configure-resource-governor-in-sql-2008-to-seperate-the-classified-work-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
		<item>
		<title>Recreating spfile on ASM storage from pfile</title>
		<link>http://zhefeng.wordpress.com/2011/03/02/recreating-spfile-on-asm-storage-from-pfile/</link>
		<comments>http://zhefeng.wordpress.com/2011/03/02/recreating-spfile-on-asm-storage-from-pfile/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 22:46:42 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[[backup and recovery]]]></category>
		<category><![CDATA[asm]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[pfile]]></category>
		<category><![CDATA[spfile]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=199</guid>
		<description><![CDATA[Sometimes when you strewed up with parameters, you need to use the pfile as stepstone to undo the changes in spfile. How does it happen if your spfile sits on ASM storage? Here is an workaround. 1. try to screw up the db parameters SQL&#62; show parameter memory NAME TYPE VALUE &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; hi_shared_memory_address [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=199&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes when you strewed up with parameters, you need to use the pfile as stepstone to undo the changes in spfile. How does it happen if your spfile sits on ASM storage? Here is an workaround.</p>
<p>1. try to screw up the db parameters<br />
SQL&gt; show parameter memory</p>
<p>NAME                                 TYPE        VALUE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
hi_shared_memory_address             integer     0<br />
memory_max_target                    big integer 1520M<br />
memory_target                        big integer 1520M<br />
shared_memory_address                integer     0<br />
SQL&gt; alter system set memory_max_target=0 scope=spfile;<br />
System altered.</p>
<p>2. now bounce the instance, db will complain about the new settings<br />
SQL&gt; shutdown<br />
Database closed.<br />
Database dismounted.<br />
ORACLE instance shut down.<br />
SQL&gt; startup<br />
ORA-01078: failure in processing system parameters<br />
ORA-00837: Specified value of MEMORY_TARGET greater than MEMORY_MAX_TARGET</p>
<p>3. in my case the spfile sits on ASM<br />
ASMCMD&gt; ls -l spfile*<br />
Type           Redund  Striped  Time             Sys  Name<br />
                                                 N    spfileorcl.ora =&gt; +DATA/ORCL/PARAMETERFILE/spfile.267.744731331</p>
<p>4. what we need to do is creating a pfile from spfile then modify parameter back to valid value, then start db from pfile<br />
1). With db not up, we can create pfile from spfile:<br />
SQL&gt; create pfile from spfile=&#8217;+DATA/orcl/spfileorcl.ora&#8217;;<br />
2). modify the value in pfile &#8216;initorcl.ora&#8217;<br />
$ vi initorcl.ora<br />
*.memory_max_target=1583349760<br />
3). startup db with pfile<br />
SQL&gt;startup mount                                  &#8211;now it will use the pfile</p>
<p>5. create the new spfile to ASM storage from &#8220;good&#8221; pfile<br />
SQL&gt; create spfile=&#8217;+DATA/ORCL/spfileorcl.ora&#8217; from pfile;<br />
File created.</p>
<p>6. watch the file name in ASM storage has been changed, which means we just had a new spfile:<br />
ASMCMD&gt; ls -l spfile*<br />
Type           Redund  Striped  Time             Sys  Name<br />
                                                 N    spfileorcl.ora =&gt; +DATA/ORCL/PARAMETERFILE/spfile.267.744733351</p>
<p>7. now change the pfile back to be the &#8220;bootstrap&#8221; of correct spfile<br />
$ cat initorcl.ora<br />
spfile=&#8217;+DATA/ORCL/spfileorcl.ora&#8217;</p>
<p>8. restart the database, it will pickup the correct spfile again<br />
$ sqlplus / as sysdba<br />
SQL&gt; startup<br />
ORACLE instance started.</p>
<p>Total System Global Area 1586708480 bytes<br />
Fixed Size                  2213736 bytes<br />
Variable Size             973080728 bytes<br />
Database Buffers          603979776 bytes<br />
Redo Buffers                7434240 bytes<br />
Database mounted.<br />
Database opened.</p>
<p>SQL&gt; show parameter spfile</p>
<p>NAME                                 TYPE        VALUE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
spfile                               string      +DATA/orcl/spfileorcl.ora</p>
<p>SQL&gt; show parameter memory</p>
<p>NAME                                 TYPE        VALUE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
hi_shared_memory_address             integer     0<br />
memory_max_target                    big integer 1520M<br />
memory_target                        big integer 1520M<br />
shared_memory_address                integer     0</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=199&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2011/03/02/recreating-spfile-on-asm-storage-from-pfile/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
		<item>
		<title>root.sh failed on 2nd node when installing Grid Infrastructure</title>
		<link>http://zhefeng.wordpress.com/2010/09/29/root-sh-failed-on-2nd-node-when-installing-grid-infrastructure/</link>
		<comments>http://zhefeng.wordpress.com/2010/09/29/root-sh-failed-on-2nd-node-when-installing-grid-infrastructure/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 20:39:05 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[[RAC]]]></category>
		<category><![CDATA[asm]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[multipath]]></category>
		<category><![CDATA[root.sh]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=184</guid>
		<description><![CDATA[when i was running root.sh for the last step of grid infra installation on second node, it failed (it was success on 1st node): root.sh failed on second node with following errors &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- DiskGroup DATA1 creation failed with the following message: ORA-15018: diskgroup cannot be created ORA-15072: command requires at least 1 regular failure groups, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=184&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>when i was running root.sh for the last step of grid infra installation on second node, it failed (it was success on 1st node):<br />
root.sh failed on second node with following errors<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
DiskGroup DATA1 creation failed with the following message:<br />
ORA-15018: diskgroup cannot be created<br />
ORA-15072: command requires at least 1 regular failure groups, discovered only 0</p>
<p>Oracle gives the reason: when you are using multipathing storage for ASM, you have to pre-configure the oracleasm file as below:</p>
<p>On all nodes,</p>
<p>1. Modify the /etc/sysconfig/oracleasm with:</p>
<p>ORACLEASM_SCANORDER=&#8221;dm&#8221;<br />
ORACLEASM_SCANEXCLUDE=&#8221;sd&#8221;</p>
<p>2. restart the asmlib by (except 1st node):<br />
# /etc/init.d/oracleasm restart</p>
<p>3. deconfigure the root.sh settings on nodes except 1st node:<br />
$GRID_HOME/crs/install/rootcrs.pl -verbose -deconfig -force</p>
<p>4. Run root.sh again on the 2nd node (or other nodes)</p>
<p>Oracle Metalink Doc:<br />
11GR2 GRID INFRASTRUCTURE INSTALLATION FAILS WHEN RUNNING ROOT.SH ON NODE 2 OF RAC [ID 1059847.1]</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=184&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2010/09/29/root-sh-failed-on-2nd-node-when-installing-grid-infrastructure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
		<item>
		<title>how to deinstall the failed 11gR2 grid infrastructure</title>
		<link>http://zhefeng.wordpress.com/2010/09/27/how-to-deinstall-the-failed-11gr2-grid-infrasture/</link>
		<comments>http://zhefeng.wordpress.com/2010/09/27/how-to-deinstall-the-failed-11gr2-grid-infrasture/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 18:39:26 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[[RAC]]]></category>
		<category><![CDATA[11gR2]]></category>
		<category><![CDATA[grid infrastructure]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=180</guid>
		<description><![CDATA[Two parts are involved: first deconfigure, then deinstall Deconfigure and Reconfigure of Grid Infrastructure Cluster: Identify cause of root.sh failure by reviewing logs in $GRID_HOME/cfgtoollogs/crsconfig and $GRID_HOME/log, once cause is identified, deconfigure and reconfigure with steps below &#8211; please keep in mind that you will need wait till each step finishes successfully before move to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=180&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Two parts are involved: first deconfigure, then deinstall</p>
<p>Deconfigure and Reconfigure of Grid Infrastructure Cluster:</p>
<p>Identify cause of root.sh failure by reviewing logs in $GRID_HOME/cfgtoollogs/crsconfig and $GRID_HOME/log, once cause is identified, deconfigure and reconfigure with steps below &#8211; please keep in mind that you will need wait till each step finishes successfully before move to next one:</p>
<p>For Step1 and 2, you can skip node(s) on which you didn&#8217;t execute root.sh yet.</p>
<p>        Step 1: As root, run &#8220;$GRID_HOME/crs/install/rootcrs.pl -verbose -deconfig -force&#8221; on all nodes, except the last one.</p>
<p>        Step 2: As root, run &#8220;$GRID_HOME/crs/install/rootcrs.pl -verbose -deconfig -force -lastnode&#8221; on last node. This command will zero out OCR and VD disk also.</p>
<p>        Step 3: As root, run $GRID_HOME/root.sh on first node</p>
<p>        Step 4: As root, run $GRID_HOME/root.sh on all other node(s), except last one.<br />
        Step 5: As root, run $GRID_HOME/root.sh on last node.</p>
<p>Deinstall of Grid Infrastructure Cluster:</p>
<p>Case 1: &#8220;root.sh&#8221; never ran on this cluster, then as grid user, execute $GRID_HOME/deinstall/deinstall</p>
<p>Case 2: &#8220;root.sh&#8221; already ran, then follow the step below &#8211; please keep in mind that you will need wait till each step finishes successfully before move to next one:</p>
<p>        Step 1: As root, run &#8220;$GRID_HOME/crs/install/rootcrs.pl -verbose -deconfig -force&#8221; on all node, except the last one.</p>
<p>        Step 2: As root, run &#8220;$GRID_HOME/crs/install/rootcrs.pl -verbose -deconfig -force -lastnode&#8221; on last node. This command will zero out OCR and VD disk also.</p>
<p>        Step 3: As grid user, run $GRID_HOME/deinstall/deinstall</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/180/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=180&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2010/09/27/how-to-deinstall-the-failed-11gr2-grid-infrasture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle 10g ASM/RAW storage migration</title>
		<link>http://zhefeng.wordpress.com/2010/09/07/oracle-10g-asmraw-storage-migration/</link>
		<comments>http://zhefeng.wordpress.com/2010/09/07/oracle-10g-asmraw-storage-migration/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 17:47:56 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[[RAC]]]></category>
		<category><![CDATA[10g]]></category>
		<category><![CDATA[asm]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[OCR]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[raw]]></category>
		<category><![CDATA[SAN]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=178</guid>
		<description><![CDATA[Objective: we want to migrate the whole shared storage from old SAN to new SAN without re-installing the whole Oracle RAC Scenario: 1.Current structure [Nodes] ## eth1-Public 10.0.0.101 vmrac01 vmrac01.test.com 10.0.0.102 vmrac02 vmrac02.test.com ## eth0-Private 192.168.199.1 vmracprv01 vmracprv01.test.com 192.168.199.2 vmracprv02 vmracprv02.test.com ## VIP 10.0.0.103 vmracvip01 vmracvip01.test.com 10.0.0.104 vmracvip02 vmracvip02.test.com [Storage] Both ORACLE_HOME are local: ORACLE_HOME=/database/oracle/10grac/db [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=178&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Objective:<br />
we want to migrate the whole shared storage from old SAN to new SAN without re-installing the whole Oracle RAC </p>
<p>Scenario:<br />
1.Current structure<br />
[Nodes]<br />
## eth1-Public<br />
10.0.0.101   vmrac01            vmrac01.test.com<br />
10.0.0.102   vmrac02            vmrac02.test.com<br />
## eth0-Private<br />
192.168.199.1   vmracprv01         vmracprv01.test.com<br />
192.168.199.2   vmracprv02         vmracprv02.test.com<br />
## VIP<br />
10.0.0.103   vmracvip01         vmracvip01.test.com<br />
10.0.0.104   vmracvip02         vmracvip02.test.com</p>
<p>[Storage]<br />
Both ORACLE_HOME are local:<br />
ORACLE_HOME=/database/oracle/10grac/db<br />
CRS_HOME=/database/oracle/10grac/crs</p>
<p>Shared LUN display (3 partitions, 2*256M for OCR&amp;VOTING, 1*20G for ASM)<br />
Disk /dev/sdb: 21.4 GB, 21474836480 bytes<br />
255 heads, 63 sectors/track, 2610 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>   Device Boot      Start         End      Blocks   Id  System<br />
/dev/sdb1               1          32      257008+  83  Linux<br />
/dev/sdb2              33          64      257040   83  Linux<br />
/dev/sdb3              65        2610    20450745   83  Linux</p>
<p>OCR and Voting are on RAW device: /dev/sdb1  /dev/sdb2</p>
<p>ASM disks<br />
bash-3.1$ export ORACLE_SID=+ASM1<br />
bash-3.1$ asmcmd<br />
ASMCMD&gt; lsdg<br />
State    Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name<br />
MOUNTED  EXTERN  N      N         512   4096  1048576     19971    17925                0           17925              0  DG1/</p>
<p>2. New storage (sdc 10G)<br />
1). new LUN added<br />
[root@vmrac01 bin]# fdisk -l</p>
<p>Disk /dev/sda: 26.8 GB, 26843545600 bytes<br />
255 heads, 63 sectors/track, 3263 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>   Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1          13      104391   83  Linux<br />
/dev/sda2              14         535     4192965   82  Linux swap / Solaris<br />
/dev/sda3             536        3263    21912660   83  Linux</p>
<p>Disk /dev/sdb: 21.4 GB, 21474836480 bytes<br />
255 heads, 63 sectors/track, 2610 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>   Device Boot      Start         End      Blocks   Id  System<br />
/dev/sdb1               1          32      257008+  83  Linux<br />
/dev/sdb2              33          64      257040   83  Linux<br />
/dev/sdb3              65        2610    20450745   83  Linux</p>
<p>Disk /dev/sdc: 10.7 GB, 10737418240 bytes<br />
255 heads, 63 sectors/track, 1305 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>2). Partition the new LUN to 3 partitions<br />
Disk /dev/sdc: 10.7 GB, 10737418240 bytes<br />
255 heads, 63 sectors/track, 1305 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>   Device Boot      Start         End      Blocks   Id  System<br />
/dev/sdc1               1          32      257008+  83  Linux<br />
/dev/sdc2              33          64      257040   83  Linux<br />
/dev/sdc3              65        1305     9968332+  83  Linux</p>
<p>3). clone data from previous raw disks<br />
**shutdown db and crs first to make sure there is no change for raw disks!<br />
#dd if=/dev/raw/raw1 of=/dev/sdc1<br />
514017+0 records in<br />
514017+0 records out<br />
263176704 bytes (263 MB) copied, 252.812 seconds, 1.0 MB/s</p>
<p>#dd if=/dev/raw/raw2 of=/dev/sdc2<br />
514080+0 records in<br />
514080+0 records out<br />
263208960 bytes (263 MB) copied, 267.868 seconds, 983 kB/s</p>
<p>4).&#8221;cheating&#8221; the Oracle by re-binding to new device on both nodes<br />
**old binding<br />
Step1: add entries to /etc/udev/rules.d/60-raw.rules<br />
ACTION==&#8221;add&#8221;, KERNEL==&#8221;sdb1&#8243;, RUN+=&#8221;/bin/raw /dev/raw/raw1 %N&#8221;<br />
ACTION==&#8221;add&#8221;, KERNEL==&#8221;sdb2&#8243;, RUN+=&#8221;/bin/raw /dev/raw/raw2 %N&#8221;</p>
<p>Step2: For the mapping to have immediate effect, run below command<br />
#raw /dev/raw/raw1 /dev/sdb1<br />
#raw /dev/raw/raw2 /dev/sdb2</p>
<p>Step3: Run the following commands and add them the /etc/rc.local file.<br />
#chown oracle:dba /dev/raw/raw1<br />
#chown oracle:dba /dev/raw/raw2<br />
#chmod 660 /dev/raw/raw1<br />
#chmod 660 /dev/raw/raw2<br />
#chown oracle:dba /dev/sdb1<br />
#chown oracle:dba /dev/sdb2<br />
#chmod 660 /dev/sdb1<br />
#chmod 660 /dev/sdb2</p>
<p>**new binding on both node<br />
Step1: editing /etc/udev/rules.d/60-raw.rules<br />
ACTION==&#8221;add&#8221;, KERNEL==&#8221;sdc1&#8243;, RUN+=&#8221;/bin/raw /dev/raw/raw1 %N&#8221;<br />
ACTION==&#8221;add&#8221;, KERNEL==&#8221;sdc2&#8243;, RUN+=&#8221;/bin/raw /dev/raw/raw2 %N&#8221;</p>
<p>Step2: mapping immediately<br />
#raw /dev/raw/raw1 /dev/sdc1<br />
#raw /dev/raw/raw2 /dev/sdc2</p>
<p>Step3:permission and edit /etc/rc.local<br />
#chown oracle:dba /dev/raw/raw1<br />
#chown oracle:dba /dev/raw/raw2<br />
#chmod 660 /dev/raw/raw1<br />
#chmod 660 /dev/raw/raw2<br />
#chown oracle:dba /dev/sdc1<br />
#chown oracle:dba /dev/sdc2<br />
#chmod 660 /dev/sdc1<br />
#chmod 660 /dev/sdc2</p>
<p>5). startup crs and oracle db, check the database, everything works fine after switching the raw disks!</p>
<p>3. ASM disk group migration<br />
1). Mark the new disk sdc3 on one node<br />
# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc3<br />
Marking disk &#8220;/dev/sdc3&#8243; as an ASM disk: [  OK  ]</p>
<p>2). scan disk on the other node<br />
[root@vanpgvmrac02 bin]# /etc/init.d/oracleasm scandisks<br />
Scanning system for ASM disks: [  OK  ]</p>
<p>3). now verify the new disk was marked on both node<br />
[root@vmrac01 disks]# /etc/init.d/oracleasm listdisks<br />
VOL1<br />
VOL2</p>
<p>[root@vmrac02 bin]# /etc/init.d/oracleasm listdisks<br />
VOL1<br />
VOL2</p>
<p>4). add new disk to DISKGROUP (under asm instance)<br />
$export ORACLE_SID=+ASM1<br />
$sqlplus / as sysdba<br />
sql&gt;alter diskgroup DG1 add disk VOL2<br />
&#8211;wait rebalancing<br />
sql&gt;select * from v$asm_operation</p>
<p>5). remove old disk from DISKGROUP<br />
sql&gt;alter diskgroup DG1 drop disk VOL1<br />
&#8211;wait until rebalancing finished<br />
sql&gt;select * from v$asm_operation<br />
GROUP_NUMBER OPERATION       STATE             POWER     ACTUAL      SOFAR<br />
&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br />
  EST_WORK   EST_RATE EST_MINUTES<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8211;<br />
           1 REBAL           RUN                   1          1          2<br />
      1374         30          45</p>
<p>6). verify the database and asm, everything is ok!</p>
<p>7). clean-up the old disk confiruations<br />
[root@vmrac01 bin]# /etc/init.d/oracleasm deletedisk VOL1<br />
Removing ASM disk &#8220;VOL1&#8243;: [  OK  ]<br />
[root@vmrac01 bin]# /etc/init.d/oracleasm listdisks<br />
VOL2</p>
<p>[root@vmrac02 ~]# /etc/init.d/oracleasm scandisks<br />
Scanning system for ASM disks: [  OK  ]<br />
[root@vmrac02 ~]# /etc/init.d/oracleasm listdisks<br />
VOL2</p>
<p>8). wipe-off the partitions for sdb.</p>
<p>Reference:<br />
1. Exact Steps To Migrate ASM Diskgroups To Another SAN Without Downtime. [ID 837308.1]<br />
2. Previous doc &#8220;VMRAC installation&#8221; task 130.2008.09.12<br />
3. OCR / Vote disk Maintenance Operations: (ADD/REMOVE/REPLACE/MOVE), including moving from RAW Devices to Block Devices. [ID 428681.1]<br />
4. ASM using ASMLib and Raw Devices</p>
<p>http://www.oracle-base.com/articles/10g/ASMUsingASMLibAndRawDevices.php</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/178/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=178&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2010/09/07/oracle-10g-asmraw-storage-migration/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
		<item>
		<title>Sth. about checkpoint</title>
		<link>http://zhefeng.wordpress.com/2010/06/09/sth-about-checkpoint/</link>
		<comments>http://zhefeng.wordpress.com/2010/06/09/sth-about-checkpoint/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 22:31:46 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[1. Oracle]]></category>
		<category><![CDATA[[System Performance tuning]]]></category>
		<category><![CDATA[checkpoint]]></category>
		<category><![CDATA[dbw]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=176</guid>
		<description><![CDATA[reading a article about checkpoint on metalink(Checkpoint Tuning and Troubleshooting Guide [ID 147468.1]) Here are some good points for checkpoint: Oracle writes the dirty buffers to disk only on certain conditions: &#8211; A shadow process must scan more than one-quarter of the db_block_buffer parameter. &#8211; Every three seconds. &#8211; When a checkpoint is produced. A [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=176&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>reading a article about checkpoint on metalink(Checkpoint Tuning and Troubleshooting Guide [ID 147468.1])</p>
<p>Here are some good points for checkpoint:</p>
<p>Oracle writes the dirty buffers to disk only on certain conditions:<br />
  &#8211; A shadow process must scan more than one-quarter of the db_block_buffer<br />
     parameter.<br />
  &#8211; Every three seconds.<br />
  &#8211; When a checkpoint is produced.</p>
<p>A checkpoint is realized on five types of events:<br />
  &#8211; At each switch of the redo log files.<br />
  &#8211; When the delay for LOG_CHECKPOINT_TIMEOUT is reached.<br />
  &#8211; When the size in bytes corresponding to :<br />
     (LOG_CHECKPOINT_INTERVAL* size of IO OS blocks)<br />
     is written on the current redo log file.<br />
  &#8211;  Directly by the ALTER SYSTEM SWITCH LOGFILE command.<br />
  &#8211; Directly with the ALTER SYSTEM CHECKPOINT command.</p>
<p>During a checkpoint the following occurs:<br />
 &#8211;  The database writer (DBWR) writes all modified database<br />
    blocks in the buffer cache back to datafiles,<br />
 &#8211;  Checkpoint process (ckpt) updates the headers of all<br />
    the datafiles to indicate when the last checkpoint<br />
    occurred (SCN)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=176&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2010/06/09/sth-about-checkpoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
		<item>
		<title>Can&#8217;t compile a stored procedure when it&#8217;s locked</title>
		<link>http://zhefeng.wordpress.com/2010/05/25/cant-compile-a-stored-procedure-when-its-locked/</link>
		<comments>http://zhefeng.wordpress.com/2010/05/25/cant-compile-a-stored-procedure-when-its-locked/#comments</comments>
		<pubDate>Tue, 25 May 2010 18:25:27 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[1. Oracle]]></category>
		<category><![CDATA[[PL/SQL dev&tuning]]]></category>
		<category><![CDATA[lock]]></category>
		<category><![CDATA[ora-4021]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=173</guid>
		<description><![CDATA[Trying to recompile a procedure causes the application to hang (ie: SQL*Plus hangs after submitting the statement). Eventually ORA-4021 errors occur after the timeout (usually 5 minutes). Here is the soluation from metalink: Note:ID 107756.1 Error: ORA 4021 Text: time-out occurred while waiting to lock object &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; Cause: While trying to lock a library object, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=173&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>  Trying to recompile a procedure causes the application to hang<br />
(ie: SQL*Plus hangs after submitting the statement). Eventually ORA-4021 errors<br />
occur after the timeout (usually 5 minutes). Here is the soluation from metalink:<br />
Note:ID 107756.1</p>
<p>Error:  ORA 4021<br />
Text:   time-out occurred while waiting to lock object<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Cause:  While trying to lock a library object, a time-out occurred.<br />
Action: Retry the operation later.</p>
<p>Solution Description<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>  Verify that the package is not locked by another user by selecting from<br />
V$ACCESS view.  To do this, run:</p>
<p>SELECT * FROM v$access WHERE object = &#8221;;</p>
<p>Where  is the package name (usually in all uppercase).  If there is a row<br />
returned, then the package is already locked and cannot be dropped until the<br />
lock is released.  Returned from the query above will be the SID that has this<br />
locked. You can then use this to find out which session has obtained the lock.</p>
<p>  In some cases, that session might have been killed and will not show up.  If<br />
this happens, the lock will not be release immediately.  Waiting for PMON to<br />
clean up the lock might take some time. The fastest way to clean up the lock<br />
is to recycle the database instance.</p>
<p>  If an ORA-4021 error is not returned and the command continues to hang after<br />
issuing the CREATE OR REPLACE or DROP statment, you will need to do further<br />
analysis see where the hang is occuring. A starting point is to have a<br />
look in v$session_wait, see the referenced NOTE.61552.1 for how to analyze hang<br />
situations in general</p>
<p>Solution Explanation<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Consider the following example:</p>
<p>Session 1:</p>
<p>create or replace procedure lockit(secs in number) as<br />
shuttime date;<br />
begin<br />
  shuttime := sysdate + secs/(24*60*60);<br />
  while sysdate &lt;= shuttime loop<br />
     null;<br />
  end loop;<br />
end;<br />
/<br />
show err</p>
<p>begin<br />
&#8211; wait 10 minutes<br />
  lockit(600);<br />
end;<br />
/              </p>
<p>Session 2:<br />
create or replace procedure lockit as<br />
begin<br />
       null;<br />
end;<br />
/  </p>
<p>Result: hang and eventually (the timeout is 5 minutes):</p>
<p>create or replace procedure lockit as<br />
*<br />
ERROR at line 1:<br />
ORA-04021: timeout occurred while waiting to lock object LOCKIT</p>
<p>Session 3:</p>
<p>connect  / as sysdba<br />
col owner for a10<br />
col object for a15<br />
select * from v$access where object = &#039;LOCKIT&#039;;</p>
<p>Result:<br />
       SID OWNER      OBJECT          TYPE<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
         9 OPS$HNAPEL LOCKIT          PROCEDURE    </p>
<p>select sid, event from v$session_wait;</p>
<p>Result:</p>
<p>       SID EVENT<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
         9 null event<br />
&#8230;<br />
        12 library cache pin</p>
<p>In the above result, the blocking sid 9 waits for nothing while session 12, the<br />
hanging session, is waiting for event library cache pin.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/173/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=173&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2010/05/25/cant-compile-a-stored-procedure-when-its-locked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
		<item>
		<title>How to migrate sql cluster between domains</title>
		<link>http://zhefeng.wordpress.com/2010/03/17/how-to-migrate-sql-cluster-between-domains/</link>
		<comments>http://zhefeng.wordpress.com/2010/03/17/how-to-migrate-sql-cluster-between-domains/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 00:54:33 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[3. MS SQL Server]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=167</guid>
		<description><![CDATA[Migrating SQL Server 2005/2000 cluster from one domain to the other domain is not supported by Microsoft. However, here is the way how to do that. i used this way to migrate our production cluster sucessfully. 1. Current settings (active – passive mode) Cluster name: clustest Cluster management IP: 10.0.0.142 Virtual server Name: clustestvip1.test.com VIP: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=167&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Migrating SQL Server 2005/2000 cluster from one domain to the other domain is not supported by Microsoft. However, here is the way how to do that.<br />
i used this way to migrate our production cluster sucessfully.</p>
<p>1. Current settings (active – passive mode)<br />
Cluster name: clustest<br />
Cluster management IP: 10.0.0.142<br />
Virtual server Name: clustestvip1.test.com<br />
VIP: 10.0.0.144<br />
Service account: test\service.product<br />
Cluster group: test\sqlcluster<br />
Node1:<br />
Name –dbnode1.test.com<br />
Physical IP: 10.0.0.140</p>
<p>Node2:<br />
Name – dbnode2.test.com<br />
Physical IP: 10.0.0.204</p>
<p>2. Objective<br />
(1). To change the domain from test.com to test1.com<br />
(2). To change the service account from test\service.acc to test1\service.act<br />
(3). Make sure the sql cluster is still functional after changing</p>
<p>3. Testing steps<br />
(1). Take all cluster resources offline (except the quorum, which cannot be taken offline)<br />
(2). Stop the cluster service on both nodes and change startup type to “manual”<br />
(3). Change the domain of each machine to the new domain and reboot<br />
(4). After reboot, on each machine, change the cluster and SQL service accounts to accounts in the new domain (test\service.acc -&gt;test1\service.act).<br />
Note: according to MSKB 915846 it should be “On one of the cluster nodes, use SQL Server Configuration Manager to change the service account to the new account.”<br />
That’s not true, and you got error from there, have to do it on both nodes in services.msc.<br />
(5). Add the cluster and SQL service accounts to the local Adminstrators group.<br />
(6). Run gpedit.msc to grant the following rights to the new service account:<br />
Path: “Local Computer Policy” -&gt; “Windows Settings” -&gt; “Security Settings” -&gt; “Local Policies” -&gt;”User Rights Assignment”<br />
*Act as part of the operating system<br />
*Adjust memory quotas for a process<br />
*Back up files and directories.<br />
*Debug programs<br />
*Increase scheduling priority<br />
*Increase quotas (not in windows 2003).<br />
*Load and unload device drivers.<br />
*Lock pages in memory<br />
*Log on as a batch job<br />
*Log on as a service<br />
*Manage auditing and security log<br />
*Replace a process level token<br />
*Restore files and directories<br />
7). Update the domain groups SID for cluster services (sql 2000 skip this step)<br />
There are domain groups related to old domain name as below which couldn’t be changed in AD(you can’t find them! They only appear in register as SID at this branch: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.X\Setup).<br />
So what we need to do is just find the old group sid in registry and replace it with new group sid. Here are the steps:<br />
a. find old cluster group sid by logging in as old service account, then run “whoami /groups” in dos prompt<br />
b. in this case, the service account is service.acc, and cluster group is : test\sqlcluster<br />
c. find the sid for test\sqlcluster is:<br />
S-1-5-21-1679026800-3574736516-1101542067-14559<br />
d. same way to find the new group sid for test1\sqlcluster is:<br />
S-1-5-21-2789037367-2132044359-1364708090-24619<br />
e: replace the old sid with new sid under branch (do a small search there) : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\<br />
8). Reboot both nodes<br />
9). Start the cluster service on both machines (put them back to “automatic” mode again)<br />
10). Bring cluster resources online</p>
<p>Reference:<br />
1. Changing the Domain for a SQL 2005 Cluster </p>
<p>http://nyc-dba.blogspot.com/2007/01/changing-domain-for-sql-2005-cluster.html</p>
<p>2. How to move a Windows Server cluster from one domain to another</p>
<p>http://support.microsoft.com/kb/269196</p>
<p>3. Best practices that you can use to set up domain groups and solutions to problems that may occur when you set up a domain group when you install a SQL Server 2005 failover cluster</p>
<p>http://support.microsoft.com/kb/915846</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=167&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2010/03/17/how-to-migrate-sql-cluster-between-domains/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
		<item>
		<title>Why Isn&#8217;t Oracle Using My Index?!</title>
		<link>http://zhefeng.wordpress.com/2010/03/12/why-isnt-oracle-using-my-index/</link>
		<comments>http://zhefeng.wordpress.com/2010/03/12/why-isnt-oracle-using-my-index/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 00:02:05 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[[System Performance tuning]]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[optimizer]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=165</guid>
		<description><![CDATA[By Jonathan Lewis http://www.dbazine.com/oracle/or-articles/jlewis12 The question in the title of this piece is probably the single most frequently occurring question that appears in the Metalink forums and Usenet newsgroups. This article uses a test case that you can rebuild on your own systems to demonstrate the most fundamental issues with how cost-based optimisation works. And [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=165&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>By Jonathan Lewis </p>
<p>http://www.dbazine.com/oracle/or-articles/jlewis12</p>
<p>The question in the title of this piece is probably the single most frequently occurring question that appears in the Metalink forums and Usenet newsgroups. This article uses a test case that you can rebuild on your own systems to demonstrate the most fundamental issues with how cost-based optimisation works. And at the end of the article, you should be much better equipped to give an answer the next time you hear that dreaded question.</p>
<p>Because of the wide variety of options that are available when installing Oracle, it isn&#8217;t usually safe to predict exactly what will happen when someone runs a script that you have dictated to them. But I&#8217;m going to risk it, in the hope that your database is a fairly vanilla installation, with the default values for the mostly commonly tweaked parameters. The example has been built and tested on an 8.1.7 database with the db_block_size set to the commonly used value of 8K and the db_file_multiblock_read_count set to the equally commonly used value 8. The results may be a little different under Oracle 9.2</p>
<p>Run the script from Figure 1, which creates a couple of tables, then indexes and analyses them.</p>
<p> create table t1 as<br />
 select<br />
          trunc((rownum-1)/15)  n1,<br />
     trunc((rownum-1)/15)       n2,<br />
          rpad(&#8216;x&#8217;, 215)        v1<br />
 from all_objects&lt;<br />
 where rownum &lt;= 3000;</p>
<p> create table t2 as<br />
 select<br />
     mod(rownum,200) n1,<br />
     mod(rownum,200) n2,<br />
     rpad(&#039;x&#039;,215) v1<br />
     from all_objects<br />
     where rownum &lt;= 3000;</p>
<p> create index t1_i1 on t1(N1);<br />
 create index t2_i1 on t2(n1);</p>
<p> analyze table t1 compute<br />
 statistics;<br />
 analyze table t2 compute<br />
 statistics;</p>
<p>Figure 1: The test data sets.</p>
<p>Once you have got this data in place, you might want to convince yourself that the two sets of data are identical — in particular, that the N1 columns in both data sets have values ranging from 0 to 199, with 15 occurrences of each value. You might try the following check:</p>
<p>select n1, count(*)<br />
from t1<br />
group by n1;</p>
<p>and the matching query against T2 to prove the point.</p>
<p>If you then execute the queries:</p>
<p>select * from t1 where n1 = 45;<br />
select * from t2 where n1 = 45;</p>
<p>You will find that each query returns 15 rows. However if you</p>
<p>set autotrace traceonly explain</p>
<p>you will discover that the two queries have different execution paths.</p>
<p>The query against table T1 uses the index, but the query against table T2 does a full tablescan.</p>
<p>So you have two sets of identical data, with dramatically different access paths for the same query.<br />
What Happened to the Index?</p>
<p>Note: if you&#039;ve ever come across any of those &quot;magic number&quot; guidelines regarding the use of indexes, e.g., &quot;Oracle will use an index for less than 23 percent, 10 percent, 2 percent (pick number at random) of the data,&quot; then you may at this stage begin to doubt their validity. In this example, Oracle has used a tablescan for 15 rows out of 3,000, i.e., for just one half of one percent of the data!</p>
<p>To investigate problems like this, there is one very simple ploy that I always try as the first step: Put in some hints to make Oracle do what I think it ought to be doing, and see if that gives me any clues.</p>
<p>In this case, a simple hint:</p>
<p>/*+ index(t2, t2_i1) */</p>
<p>is sufficient to switch Oracle from the full tablescan to the indexed access path. The three paths with costs (abbreviated to C=nnn) are shown in Figure 2:</p>
<p>select * from t1 where n1 = 45;</p>
<p>EXECUTION PLAN<br />
&#8212;&#8212;&#8212;&#8212;&#8211;<br />
TABLE ACCESS BY INDEX ROWID OF T1 (C=2)<br />
  INDEX(RANGE SCAN) OF T1_I1 (C=1)</p>
<p>select * from t2 where n1 = 45;</p>
<p>EXECUTION PLAN<br />
&#8212;&#8212;&#8212;&#8212;&#8211;<br />
TABLE ACCESS FULL OF T2 (C=15)</p>
<p>select /*+ index(t2 t2_i1) */<br />
       *<br />
from t1<br />
where n1 = 45;</p>
<p>EXECUTION PLAN<br />
&#8212;&#8212;&#8212;&#8212;&#8211;<br />
TABLE ACCESS BY INDEX ROWID OF T2 (C=16)<br />
  INDEX(RANGE SCAN) OF T2_I1 (C=1) </p>
<p>Figure 2: The different queries and their costs.</p>
<p>So why hasn&#039;t Oracle used the index by default in for the T2 query? Easy — as the execution plan shows, the cost of doing the tablescan is cheaper than the cost of using the index.<br />
Why is the Tablescan Cheaper?</p>
<p>This, of course, is simply begging the question. Why is the cost of the tablescan cheaper than the cost of using the index?</p>
<p>By looking into this question, you uncover the key mechanisms (and critically erroneous assumptions) of the Cost Based Optimiser.</p>
<p>Let&#039;s start by examining the indexes by running the query:</p>
<p>select<br />
      table_name,<br />
      blevel,<br />
            avg_data_blocks_per_key,<br />
            avg_leaf_blocks_per_key,<br />
            clustering_factor<br />
from     user_indexes;</p>
<p>The results are given in the table below:<br />
  	T1 	T2<br />
Blevel 	1 	1<br />
Data block / key 	1 	15<br />
Leaf block / key 	1 	1<br />
Clustering factor 	96 	3000</p>
<p>Note particularly the value for &quot;data blocks per key.&quot; This is the number of different blocks in the table that Oracle thinks it will have to visit if you execute a query that contains an equality test on a complete key value for this index.</p>
<p>So where do the costs for our queries come from? As far as Oracle is concerned, if we fire in the key value 45, we get the data from table T1 by hitting one index leaf block and one table block — two blocks, so a cost of two.</p>
<p>If we try the same with table T2, we have to hit one index leaf block and 15 table blocks — a total of 16 blocks, so a cost of 16.</p>
<p>Clearly, according to this viewpoint, the index on table T1 is much more desirable than the index on table T2. This leaves two questions outstanding, though:</p>
<p>Where does the tablescan cost come from, and why are the figures for the avg_data_blocks_per_key so different between the two tables?</p>
<p>The answer to the second question is simple. Look back at the definition of table T1 — it uses the trunc() function to generate the N1 values, dividing the &quot;rownum &#8211; 1 &quot;by 15 and truncating.</p>
<p>     Trunc(675/15) = 45<br />
     Trunc(676/15) = 45<br />
           …<br />
     Trunc(689/15) = 45</p>
<p>All the rows with the value 45 do actually appear one after the other in a tight little clump (probably all fitting one data block) in the table.</p>
<p>Table T2 uses the mod() function to generate the N1 values, using modulus 200 on the rownum:</p>
<p>      mod(45,200) = 45<br />
      mod(245,200) = 45<br />
            …<br />
      mod(2845,200) = 45</p>
<p>The rows with the value 45 appear every two hundredth position in the table (probably resulting in no more than one row in every relevant block).</p>
<p>By doing the analyze, Oracle was able to get a perfect description of the data scatter in our table. So the optimiser was able to work out exactly how many blocks Oracle would have to visit to answer our query — and, in simple cases, the number of block visits is the cost of the query.<br />
But Why the Tablescan?</p>
<p>So we see that an indexed access into T2 is more expensive than the same path into T1, but why has Oracle switched to the tablescan?</p>
<p>This brings us to the two simple-minded, and rather inappropriate, assumptions that Oracle makes.</p>
<p>The first is that every block acquisition equates to a physical disk read, and the second is that a multiblock read is just as quick as a single block read.</p>
<p>So what impact do these assumptions have on our experiment?</p>
<p>If you query the user_tables view with the following SQL:</p>
<p>select<br />
      table_name,<br />
      blocks<br />
from user_tables;</p>
<p>you will find that our two tables each cover 96 blocks.</p>
<p>At the start of the article, I pointed out that the test case was running a version 8 system with the value 8 for the db_file_multiblock_read_count.</p>
<p>Roughly speaking, Oracle has decided that it can read the entire 96 block table in 96/8 = 12 disk read requests.</p>
<p>Since it takes 16 block (= disk read) requests to access the table by index, it is clearer quicker (from Oracle&#039;s sadly deluded perspective) to scan the table — after all 12 is less than 16.</p>
<p>Voila! If the data you are targetting is suitably scattered across the table, you get tablescans even for a very small percentage of the data — a problem that can be exaggerated in the case of very big blocks and very small rows.<br />
Correction</p>
<p>In fact, you will have noticed that my calculated number of scan reads was 12, whilst the cost reported in the execution plan was 15. It is a slight simplfication to say that the cost of a tablescan (or an index fast full scan for that matter) is</p>
<p>     &#039;number of blocks&#039; /<br />
     db_file_multiblock_read_count.</p>
<p>Oracle uses an &quot;adjusted&quot; multi-block read value for the calculation (although it then tries to use the actual requested size when the scan starts to run).</p>
<p>For reference, the following table compares a few of the actual and adjusted values:<br />
Actual 	Adjusted<br />
4 	4.175<br />
8 	6.589<br />
16 	10.398<br />
32 	16.409<br />
64 	25.895<br />
128 	40.865</p>
<p>As you can see, Oracle makes some attempt to protect you from the error of supplying an unfeasibly large value for this parameter.</p>
<p>There is a minor change in version 9, by the way, where the tablescan cost is further adjusted by adding one to result of the division — which means tablescans in V9 are generally just a little more expensive than in V8, so indexes are just a little more likely to be used.<br />
Adjustments</p>
<p>We have seen that there are two assumptions built into the optimizer that are not very sensible.</p>
<p>    * A single block read costs just as much as a multi-block read — (not really likely, particularly when running on file systems without direction)<br />
    * A block access will be a physical disk read — (so what is the buffer cache for?)</p>
<p>Since the early days of Oracle 8.1, there have been a couple of parameters that allow us to correct these assumption in a reasonably truthful way.</p>
<p>See Tim Gorman&#039;s article for a proper description of these parameters, but briefly:</p>
<p>Optimizer_index_cost_adj takes a value between 1 and 10000 with a default of 100. Effectively, this parameter describes how cheap a single block read is compared to a multiblock read. For example the value 30 (which is often a suitable first guess for an OLTP system) would tell Oracle that a single block read costs 30% of a multiblock read. Oracle would therefore incline towards using indexed access paths for low values of this parameter.</p>
<p>Optimizer_index_caching takes a value between 0 and 100 with a default of 0. This tells Oracle to assume that that percentage of index blocks will be found in the buffer cache. In this case, setting values close to 100 encourages the use of indexes over tablescans.</p>
<p>The really nice thing about both these parameters is that they can be set to &quot;truthful&quot; values.</p>
<p>Set the optimizer_index_caching to something in the region of the &quot;buffer cache hit ratio.&quot; (You have to make your own choice about whether this should be the figure derived from the default pool, keep pool, or both).</p>
<p>The optimizer_index_cost_adj is a little more complicated. Check the typical wait times in v$system_event for the events &quot;db file scattered read&quot; (multi block reads) and &quot;db file sequential reads&quot; (single block reads). Divide the latter by the former and multiply by one hundred.<br />
Improvements</p>
<p>Don&#039;t forget that the two parameters may need to be adjusted at different times of the day and week to reflect the end-user workload. You can&#039;t just derive one pair of figures, and use them for ever.</p>
<p>Happily, in Oracle 9, things have improved. You can now collect system statistics, which are originally included just the four:</p>
<p>                + Average single block read time<br />
                + Average multi block read time<br />
                + Average actual multiblock read<br />
                + Notional usable CPU speed.</p>
<p>Suffice it to say that this feature is worth an article in its own right — but do note that the first three allow Oracle to discover the truth about the cost of multi block reads. And in fact, the CPU speed allows Oracle to work out the CPU cost of unsuitable access mechanisms like reading every single row in a block to find a specific data value and behave accordingly.</p>
<p>When you migrate to version 9, one of the first things you should investigate is the correct use of system statistics. This one feature alone may reduce the amount of time you spend trying to &quot;tune&quot; awkward SQL.</p>
<p>In passing, despite the wonderful effect of system statistics both of the optimizer adjusting parameters still apply — although the exact formula for their use seems to have changed between version 8 and version 9.<br />
Variations on a Theme</p>
<p>Of course, I have picked one very special case — equality on a single column non-unique index, where thare are no nulls in the table — and treated it very simply. (I haven&#039;t even mentioned the relevance of the index blevel and clustering_factor yet.) There are numerous different strategies that Oracle uses to work out more general cases.</p>
<p>Consider some of the cases I have conveniently overlooked:</p>
<p>                + Multi-column indexes<br />
                + Part-used multi-column indexes<br />
                + Range scans<br />
                + Unique indexes<br />
                + Non-unique indexes representing unique constraints<br />
                + Index skip scans<br />
                + Index only queries<br />
                + Bitmap indexes<br />
                + Effects of nulls</p>
<p>The list goes on and on. There is no one simple formula that tells you how Oracle works out a cost — there is only a general guideline that gives you the flavour of the approach and a list of different formulae that apply in different cases.</p>
<p>However, the purpose of this article was to make you aware of the general approach and the two assumptions built into the optimiser&#039;s strategy. And I hope that this may be enough to take you a long way down the path of understanding the (apparently) strange things that the optimiser has been known to do.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/165/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=165&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2010/03/12/why-isnt-oracle-using-my-index/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Troubleshooting Bad Execution Plans</title>
		<link>http://zhefeng.wordpress.com/2010/03/11/how-to-troubleshooting-bad-execution-plans/</link>
		<comments>http://zhefeng.wordpress.com/2010/03/11/how-to-troubleshooting-bad-execution-plans/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 19:36:01 +0000</pubDate>
		<dc:creator>zhefeng</dc:creator>
				<category><![CDATA[[System Performance tuning]]]></category>
		<category><![CDATA[execution plan]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://zhefeng.wordpress.com/?p=163</guid>
		<description><![CDATA[Very good sql tuning artical from Greg Rahn Original Link: One of the most common performance issues DBAs encounter are bad execution plans. Many try to resolve bad executions plans by setting optimizer related parameters or even hidden underscore parameters. Some even try to decipher a long and complex 10053 trace in hopes to find [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=163&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Very good sql tuning artical from Greg Rahn</p>
<p>Original Link:</p>
<p>One of the most common performance issues DBAs encounter are bad execution plans. Many try to resolve bad executions plans by setting optimizer related parameters or even hidden underscore parameters. Some even try to decipher a long and complex 10053 trace in hopes to find an answer. While changing parameters or analyzing a 10053 trace might be useful for debugging at some point, I feel there is a much more simple way to start to troubleshoot bad execution plans.</p>
<p>Verify The Query Matches The Business Question</p>
<p>This seems like an obvious thing to do, but I’ve seen numerous cases where the SQL query does not match the business question being asked. Do a quick sanity check verifying things like: join columns, group by, subqueries, etc. The last thing you want to do is consume time trying to debug a bad plan for an improperly written SQL query. Frequently I’ve found that this is the case for many of those “I’ve never got it to run to completion” queries.</p>
<p>What Influences The Execution Plan</p>
<p>I think it’s important to understand what variables influence the Optimizer in order to focus the debugging effort. There are quite a number of variables, but frequently the cause of the problem ones are: (1) non-default optimizer parameters and (2) non-representative object/system statistics. Based on my observations I would say that the most abused Optimizer parameters are:</p>
<p>    * OPTIMIZER_INDEX_CACHING<br />
    * OPTIMIZER_INDEX_COST_ADJ<br />
    * DB_FILE_MULTIBLOCK_READ_COUNT</p>
<p>Many see setting these as a solution to get the Optimizer to choose an index plan over a table scan plan, but this is problematic in several ways:</p>
<p>   1. This is a global change to a local problem<br />
   2. Although it appears to solve one problem, it is unknown how many bad execution plans resulted from this change<br />
   3. The root cause of why the index plan was not chosen is unknown, just that tweaking parameters gave the desired result<br />
   4. Using non-default parameters makes it almost impossible to correctly and effectively troubleshoot the root cause</p>
<p>Object and system statistics can have a large influence on execution plans, but few actually take the time to sanity check them during triage. These statistics exist in views like:</p>
<p>    * ALL_TAB_COL_STATISTICS<br />
    * ALL_PART_COL_STATISTICS<br />
    * ALL_INDEXES<br />
    * SYS.AUX_STATS$</p>
<p>Using GATHER_PLAN_STATISTICS With DBMS_XPLAN.DISPLAY_CURSOR</p>
<p>As a first step of triage, I would suggest executing the query with a GATHER_PLAN_STATISTICS hint followed by a call to DBMS_XPLAN.DISPLAY_CURSOR. The GATHER_PLAN_STATISTICS hint allows for the collection of extra metrics during the execution of the query. Specifically, it shows us the Optimizer’s estimated number of rows (E-Rows) and the actual number of rows (A-Rows) for each row source. If the estimates are vastly different from the actual, one probably needs to investigate why. For example: In the below plan, look at line 8. The Optimizer estimates 5,899 rows and the row source actually returns 5,479,000 rows. If the estimate is off by three orders of magnitude (1000), chances are the plan will be sub-optimal. Do note that with Nested Loop Joins you need to multiply the Starts column by the E-Rows column to get the A-Rows values (see line 10).<br />
view source<br />
print?<br />
01	select /*+ gather_plan_statistics */ &#8230; from &#8230; ;<br />
02	select * from table(dbms_xplan.display_cursor(null, null, &#8216;ALLSTATS LAST&#8217;));<br />
03<br />
04	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
05	|  Id | Operation                              | Name         | Starts | E-Rows | A-Rows |<br />
06	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
07	|   1 | SORT GROUP BY                          |              |     1  |      1 | 1      |<br />
08	|*  2 |  FILTER                                |              |     1  |        | 1728K  |<br />
09	|   3 |   NESTED LOOPS                         |              |     1  |      1 | 1728K  |<br />
10	|*  4 |    HASH JOIN                           |              |     1  |      1 | 1728K  |<br />
11	|   5 |     PARTITION LIST SINGLE              |              |     1  |   6844 | 3029   |<br />
12	|*  6 |      INDEX RANGE SCAN                  | PROV_IX13    |     1  |   6844 | 3029   |<br />
13	|   7 |     PARTITION LIST SINGLE              |              |     1  |   5899 | 5479K  |<br />
14	|*  8 |      TABLE ACCESS BY LOCAL INDEX ROWID | SERVICE      |     1  |   5899 | 5479K  |<br />
15	|*  9 |       INDEX SKIP SCAN                  | SERVICE_IX8  |     1  |   4934 | 5479K  |<br />
16	|  10 |    PARTITION LIST SINGLE               |              |  1728K |      1 | 1728K  |<br />
17	|* 11 |     INDEX RANGE SCAN                   | CLAIM_IX7    |  1728K |      1 | 1728K  |<br />
18	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Using The CARDINALITY Hint</p>
<p>Now that I’ve demonstrated how to compare the cardinality estimates to the actual number of rows, what are the debugging options? If one asserts that the Optimizer will choose the optimal plan if it can accurately estimate the number of rows, one can test using the not so well (un)documented CARDINALITY hint. The CARDINALITY hint tells the Optimizer how many rows are coming out of a row source. The hint is generally used like such:<br />
view source<br />
print?<br />
1	select /*+ cardinality(a 100) */ * from dual a;<br />
2<br />
3	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
4	| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |<br />
5	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
6	|   0 | SELECT STATEMENT  |      |   100 |   200 |     2   (0)| 00:00:01 |<br />
7	|   1 |  TABLE ACCESS FULL| DUAL |   100 |   200 |     2   (0)| 00:00:01 |<br />
8	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>In this case I told the Optimizer that DUAL would return 100 rows (when in reality it returns 1 row) as seen in the Rows column from the autotrace output. The CARDINALITY hint is one tool one can use to give the Optimizer accurate information. I usually find this the best way to triage a bad plan as it is not a global change, it only effects a single execution of a statement in my session. If luck has it that using a CARDINALITY hint yields an optimal plan, one can move on to debugging where the cardinality is being miscalculated. Generally the bad cardinality is the result of non-representative table/column stats, but it also may be due to data correlation or other factors. This is where it pays off to know and understand the size and shape of the data. If the Optimizer still chooses a bad plan even with the correct cardinality estimates, it’s time to place a call to Oracle Support as more in-depth debugging is likely required.</p>
<p>Where Cardinality Can Go Wrong</p>
<p>There are several common scenarios that can lead to inaccurate cardinality estimates. Some of those on the list are:</p>
<p>   1. Data skew: Is the NDV inaccurate due to data skew and a poor dbms_stats sample?<br />
   2. Data correlation: Are two or more predicates related to each other?<br />
   3. Out-of-range values: Is the predicate within the range of known values?<br />
   4. Use of functions in predicates: Is the 5% cardinality guess for functions accurate?<br />
   5. Stats gathering strategies: Is your stats gathering strategy yielding representative stats?</p>
<p>Some possible solutions to these issues are:</p>
<p>   1. Data skew: Choose a sample size that yields accurate NDV. Use DBMS_STATS.AUTO_SAMPLE_SIZE in 11g.<br />
   2. Data correlation: Use Extended Stats in 11g. If &lt;= 10.2.0.3 use a CARDINALITY hint if possible.<br />
   3. Out-of-range values: Gather or manually set the statistics.<br />
   4. Use of functions in predicates: Use a CARDINALITY hint where possible.<br />
   5. Stats gathering strategies: Use AUTO_SAMPLE_SIZE. Adjust only where necessary. Be mindful of tables with skewed data.</p>
<p>How To Best Work With Oracle Support</p>
<p>If you are unable to get to the root cause on your own, it is likely that you will be in contact with Oracle Support. To best assist the support analyst I would recommend you gather the following in addition to the query text:</p>
<p>   1. Output from the GATHER_PLAN_STATISTICS and DBMS_XPLAN.DISPLAY_CURSOR<br />
   2. SQLTXPLAN output. See Metalink Note 215187.1<br />
   3. 10053 trace output. See Metalink Note 225598.1<br />
   4. DDL for all objects used (and dependencies) in the query. This is best gotten as a expdp (data pump) using CONTENT=METADATA_ONLY. This will also include the object statistics.<br />
   5. Output from: select pname, pval1 from sys.aux_stats$ where sname=&#039;SYSSTATS_MAIN&#039;;<br />
   6. A copy of your init.ora</p>
<p>Having this data ready before you even make the call (or create the SR on-line) should give you a jump on getting a quick(er) resolution.</p>
<p>Summary</p>
<p>While this blog post is not meant to be a comprehensive troubleshooting guide for bad execution plans, I do hope that it does help point you in the right direction the next time you encounter one. Many of the Optimizer issues I’ve seen are due to incorrect cardinality estimates, quite often due to inaccurate NDV or the result of data correlation. I believe that if you use a systematic approach you will find that debugging bad execution plans may be as easy as just getting the cardinality estimate correct.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zhefeng.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zhefeng.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zhefeng.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zhefeng.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zhefeng.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zhefeng.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zhefeng.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zhefeng.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zhefeng.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zhefeng.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zhefeng.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zhefeng.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zhefeng.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zhefeng.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zhefeng.wordpress.com&amp;blog=4089014&amp;post=163&amp;subd=zhefeng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zhefeng.wordpress.com/2010/03/11/how-to-troubleshooting-bad-execution-plans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dc3f8d045f43921ceb3f4b19b693982b?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">zhefeng</media:title>
		</media:content>
	</item>
	</channel>
</rss>
