<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1931548025515710472</id><updated>2012-01-30T15:24:36.308+08:00</updated><title type='text'>Hemant's Oracle DBA Blog</title><subtitle type='html'>I am an Oracle Database Expert in Singapore.&lt;br&gt;

get an rss feed of this blog at http://hemantoracledba.blogspot.com/feeds/posts/default?alt=rss
&lt;br&gt;


&lt;br&gt;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default?start-index=101&amp;max-results=100'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>326</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7841747437361066057</id><published>2012-01-30T00:26:00.000+08:00</published><updated>2012-01-30T00:26:22.014+08:00</updated><title type='text'>Understanding  RESETLOGS</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Whenever we do an Incomplete Recovery (recovery until CANCEL or until a specific SCN/CHANGE#, SEQUENCE# or TIME), we have to OPEN the database with a RESETLOGS.&lt;br /&gt;&lt;br /&gt;RESETLOGS_TIME has to be indicated by Oracle if we were to query the database later.  This is the time when the RESETLOGS was issued.RESETLOGS_CHANGE# is the SCN for the database at the issuance of the command.Oracle also provides information of the RESETLOGS_ID for each "incarnation".  A RESETLOGS creates a new "incarnation" of the database.&lt;br /&gt;&lt;br /&gt;Thus, my database has this information :&lt;/div&gt;&lt;pre&gt;SQL&amp;gt; select sysdate from dual;&lt;br /&gt;&lt;br /&gt;SYSDATE&lt;br /&gt;---------&lt;br /&gt;29-JAN-12&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select resetlogs_time from v$database;&lt;br /&gt;&lt;br /&gt;RESETLOGS&lt;br /&gt;---------&lt;br /&gt;01-JAN-12&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select incarnation#, resetlogs_change#, resetlogs_time, resetlogs_id                            &lt;br /&gt;  2  from v$database_incarnation&lt;br /&gt;  3  order by 1;&lt;br /&gt;&lt;br /&gt;INCARNATION# RESETLOGS_CHANGE# RESETLOGS RESETLOGS_ID&lt;br /&gt;------------ ----------------- --------- ------------&lt;br /&gt;           1                 1 13-AUG-09    694825248&lt;br /&gt;           2            754488 30-OCT-09    701609923&lt;br /&gt;           3           4955792 01-JAN-12    771419578&lt;br /&gt;           4           4957614 01-JAN-12    771421939&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;As of today, 29-Jan, we can see that the database has undergone 4 RESETLOGS, the latest having been on 01-JAN-12 (in fact, there were two RESETLOGS that date).Why does this query report duplicate entries for the same SEQUENCE# ?&lt;/div&gt;&lt;pre&gt;SQL&amp;gt; l&lt;br /&gt;  1  select sequence#, trunc(first_time)&lt;br /&gt;  2  from v$archived_log&lt;br /&gt;  3  where first_time &amp;gt; to_date('31-DEC-11','DD-MON-RR')&lt;br /&gt;  4* order by 1&lt;br /&gt;SQL&amp;gt; /&lt;br /&gt;&lt;br /&gt; SEQUENCE# TRUNC(FIR&lt;br /&gt;---------- ---------&lt;br /&gt;         1 01-JAN-12&lt;br /&gt;         1 01-JAN-12&lt;br /&gt;         1 01-JAN-12&lt;br /&gt;         1 01-JAN-12&lt;br /&gt;         1 01-JAN-12&lt;br /&gt;         2 01-JAN-12&lt;br /&gt;         2 01-JAN-12&lt;br /&gt;         2 14-JAN-12&lt;br /&gt;         2 01-JAN-12&lt;br /&gt;         2 01-JAN-12&lt;br /&gt;         3 01-JAN-12&lt;br /&gt;         3 01-JAN-12&lt;br /&gt;         3 15-JAN-12&lt;br /&gt;         3 01-JAN-12&lt;br /&gt;         4 15-JAN-12&lt;br /&gt;         5 15-JAN-12&lt;br /&gt;       180 01-JAN-12&lt;br /&gt;       180 01-JAN-12&lt;br /&gt;       180 01-JAN-12&lt;br /&gt;       181 01-JAN-12&lt;br /&gt;       181 01-JAN-12&lt;br /&gt;       181 01-JAN-12&lt;br /&gt;       182 01-JAN-12&lt;br /&gt;       182 01-JAN-12&lt;br /&gt;&lt;br /&gt;24 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;It does seem very confusing to have SEQUENCE#1 to SEQUENCE#3 report 5 entries each.And why is there a gap between SEQUENCE#5 and SEQUENCE#180 ?  &amp;nbsp; Can we dig deeper ?&lt;/div&gt;I can collect more information thus : &lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select resetlogs_id, sequence#, trunc(first_time)&lt;br /&gt;  2  from v$archived_log&lt;br /&gt;  3  order by 1,2&lt;br /&gt;  4  /&lt;br /&gt;&lt;br /&gt;RESETLOGS_ID  SEQUENCE# TRUNC(FIR&lt;br /&gt;------------ ---------- ---------&lt;br /&gt;   701609923        179 26-DEC-11&lt;br /&gt;   701609923        180 01-JAN-12&lt;br /&gt;   701609923        180 01-JAN-12&lt;br /&gt;   701609923        180 01-JAN-12&lt;br /&gt;   701609923        181 01-JAN-12&lt;br /&gt;   701609923        181 01-JAN-12&lt;br /&gt;   701609923        181 01-JAN-12&lt;br /&gt;   701609923        182 01-JAN-12&lt;br /&gt;   701609923        182 01-JAN-12&lt;br /&gt;   771419578          1 01-JAN-12&lt;br /&gt;   771419578          1 01-JAN-12&lt;br /&gt;   771419578          1 01-JAN-12&lt;br /&gt;   771419578          1 01-JAN-12&lt;br /&gt;   771419578          2 01-JAN-12&lt;br /&gt;   771419578          2 01-JAN-12&lt;br /&gt;   771419578          2 01-JAN-12&lt;br /&gt;   771419578          2 01-JAN-12&lt;br /&gt;   771419578          3 01-JAN-12&lt;br /&gt;   771419578          3 01-JAN-12&lt;br /&gt;   771419578          3 01-JAN-12&lt;br /&gt;   771421939          1 01-JAN-12&lt;br /&gt;   771421939          2 14-JAN-12&lt;br /&gt;   771421939          3 15-JAN-12&lt;br /&gt;   771421939          4 15-JAN-12&lt;br /&gt;   771421939          5 15-JAN-12&lt;br /&gt;&lt;br /&gt;25 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;Now, I can see that the SEQUENCE# 179 to 182 are for 26-DEC-11 to 01-JAN-12 for INCARNATION#2 which existed from 30-OCT-09 to 01-JAN-12  (this information is retrieved from V$DATABASE_INCARNATION from the earlier query).  Yet, there are repeated entries from the same SEQUENCE# (180 and 181 have three entries each while 182 has two entries) !&amp;nbsp; Was each log file archived more than once ?&amp;nbsp; Similarly, in INCARNATION#3 I have three entries for each of SEQUENCE# 1 to 3.&amp;nbsp; Then, the latest INCARNATION#4&amp;nbsp; (for RESETLOGS_ID 771421939) has only 1 entry each for SEQUENCE# 1 to 5.&lt;br /&gt;&lt;br /&gt;Were there really multiple archivelogs created from SEQUENCE# 180 to 182 and again for 1 to 3 on 01-JAN-12 ?&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Here's a listing of archivelog files : &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;[oracle@linux64 2012_01_01]$ pwd&lt;br /&gt;/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_01_01&lt;br /&gt;[oracle@linux64 2012_01_01]$ ls -ltr&lt;br /&gt;total 10200&lt;br /&gt;-rw-rw---- 1 oracle oracle 5261824 Jan  1 10:59 o1_mf_1_179_7hzlzvcg_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle   90112 Jan  1 11:00 o1_mf_1_180_7hzm1ogl_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle  483840 Jan  1 11:02 o1_mf_1_181_7hzm5frg_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle  377856 Jan  1 11:12 o1_mf_1_182_7hzmst65_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle  483840 Jan  1 11:12 o1_mf_1_181_7hzmst4n_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle   90112 Jan  1 11:12 o1_mf_1_180_7hzmst70_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle 1486336 Jan  1 11:25 o1_mf_1_1_7hznjsy3_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle   15872 Jan  1 11:26 o1_mf_1_2_7hznmzh7_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle  590848 Jan  1 11:52 o1_mf_1_3_7hzp3my5_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle   15872 Jan  1 11:52 o1_mf_1_2_7hzp3mxw_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle 1486336 Jan  1 11:52 o1_mf_1_1_7hzp3mvq_.arc&lt;br /&gt;[oracle@linux64 2012_01_01]$ &lt;br /&gt;&lt;/pre&gt;That's curious !  I dont' see three archivelog files, but I do see two archivelogs for SEQUENCE# 180 and 181 and 1 and 2!!&lt;br /&gt;&lt;br /&gt;Can anyone explain this ?&lt;br /&gt;Hint : I did an OPEN RESETLOGS.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7841747437361066057?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7841747437361066057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7841747437361066057' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7841747437361066057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7841747437361066057'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2012/01/understanding-resetlogs.html' title='Understanding  RESETLOGS'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-2009601451874506449</id><published>2012-01-28T22:39:00.000+08:00</published><updated>2012-01-28T22:39:57.626+08:00</updated><title type='text'>Oracle Wiki Relaunched</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Oracle Wiki has been reluanched as &lt;a href="http://wikis.oracle.com/" target="_blank"&gt;wikis.oracle.com&lt;/a&gt; &amp;nbsp;. &amp;nbsp; It doesn't seem to be very well organized currently. &amp;nbsp;Multiple pages with the name "Home" appear at the first page and each of these are for specific product homes. &amp;nbsp;The list of "spaces" doesn't seem to include the core RDBMS product or the EBusiness Suite yet.&lt;br /&gt;&lt;br /&gt;I'll wait a week or two before deciding if I want to contribute to Oracle Wiki (or Wikis ?)&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-2009601451874506449?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/2009601451874506449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=2009601451874506449' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2009601451874506449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2009601451874506449'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2012/01/oracle-wiki-relaunched.html' title='Oracle Wiki Relaunched'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7671541902587973026</id><published>2012-01-26T10:06:00.000+08:00</published><updated>2012-01-26T10:06:01.319+08:00</updated><title type='text'>Departmental Analytics --  a "pro-local" approach ?</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Curt Monash has posted about &lt;a href="http://www.dbms2.com/2012/01/25/departmental-analytics-best-practices/" target="_blank"&gt;Departmental Analytics - best practices&lt;/a&gt;.&amp;nbsp; He is of the view that "corporate standards" should NOT be an obstacle to departments running their own Analytics implementations.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7671541902587973026?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7671541902587973026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7671541902587973026' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7671541902587973026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7671541902587973026'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2012/01/departmental-analytics-pro-local.html' title='Departmental Analytics --  a &quot;pro-local&quot; approach ?'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-1197354923923376119</id><published>2012-01-22T02:28:00.000+08:00</published><updated>2012-01-22T02:28:48.620+08:00</updated><title type='text'>Refreshing an MV on a Prebuilt Table</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;I had earlier demonstrated &lt;a href="http://hemantoracledba.blogspot.com/2009/03/materialized-view-on-prebuilt-table.html" target="_blank"&gt;creating an MV on a Prebuilt Table&lt;/a&gt;.&amp;nbsp; A few days ago, I had a question on refreshing such an MV.&lt;br /&gt;Here is a simple demonstration :&lt;/div&gt;&lt;pre&gt;SQL&amp;gt; -- create the source table&lt;br /&gt;SQL&amp;gt; create table mv_source (id number not null, item_name varchar2(30));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert  into mv_source select object_id, object_name from user_objects;&lt;br /&gt;&lt;br /&gt;6 rows created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(*) from mv_source;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         6                                                                      &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter table mv_source add constraint mv_source_pk primary key (id);&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; -- create an MV Log on the source table&lt;br /&gt;SQL&amp;gt; create materialized view log on mv_source;&lt;br /&gt;&lt;br /&gt;Materialized view log created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; -- create the MV as a prebuilt table&lt;br /&gt;SQL&amp;gt; -- e.g. this could have been via export/import ?&lt;br /&gt;SQL&amp;gt; create table my_mv as select * from mv_source;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create materialized view my_mv on prebuilt table refresh fast as select * from mv_source;&lt;br /&gt;&lt;br /&gt;Materialized view created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(*) from my_mv;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         6                                                                      &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; -- setup new data&lt;br /&gt;SQL&amp;gt; select count(*) from mlog$_mv_source;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         0                                                                      &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into mv_source values (1000000, 'AN_ITEM');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into mv_source values (2000000, 'ANOTHER_ITEM');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into mv_source values (3000000, 'THIRD_ITEM');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(*) from mlog$_mv_source;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         3                                                                      &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; -- refresh the MV&lt;br /&gt;SQL&amp;gt; exec dbms_session.session_trace_enable();&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; exec dbms_mview.refresh('MY_MV','F');&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(*) from my_mv;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         9                                                                      &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; exec dbms_session.session_trace_disable();&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from my_mv where id  &amp;gt; 999999 order by 1;&lt;br /&gt;&lt;br /&gt;        ID ITEM_NAME                                                            &lt;br /&gt;---------- ------------------------------                                       &lt;br /&gt;   1000000 AN_ITEM                                                              &lt;br /&gt;   2000000 ANOTHER_ITEM                                                         &lt;br /&gt;   3000000 THIRD_ITEM                                                           &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; -- the Snapshot log on the source table has been cleared&lt;br /&gt;SQL&amp;gt; select count(*) from mlog$_mv_source;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         0                                                                      &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;I started with the source table MV_SOURCE and then created MY_MV from this table.&amp;nbsp; New rows inserted into the source then populated the MV Log on the source.&amp;nbsp; A FAST REFRESH of the MV was executed as an Incremental Refresh rather than a full scan of the source table again !&lt;br /&gt;&lt;br /&gt;Note : Here are some of the interesting SQLs from the trace of the Refresh call :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;DELETE FROM "HEMANT"."MY_MV" SNAP$&lt;br /&gt;WHERE&lt;br /&gt; "ID" IN (SELECT DISTINCT LOG$."ID" FROM (SELECT MLOG$."ID" FROM&lt;br /&gt;  "HEMANT"."MLOG$_MV_SOURCE" MLOG$ WHERE "SNAPTIME$$" &amp;gt; :1 AND ("DMLTYPE$$" !=&lt;br /&gt;   'I')) LOG$ WHERE (LOG$."ID") NOT IN (SELECT MAS_TAB$."ID" FROM "MV_SOURCE"&lt;br /&gt;  "MAS_TAB$" WHERE LOG$."ID" = MAS_TAB$."ID"))&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MERGE INTO "HEMANT"."MY_MV" "SNA$" USING (SELECT CURRENT$."ID",&lt;br /&gt;  CURRENT$."ITEM_NAME" FROM (SELECT "MV_SOURCE"."ID" "ID",&lt;br /&gt;  "MV_SOURCE"."ITEM_NAME" "ITEM_NAME" FROM "MV_SOURCE" "MV_SOURCE") CURRENT$,&lt;br /&gt;  (SELECT DISTINCT MLOG$."ID" FROM "HEMANT"."MLOG$_MV_SOURCE" MLOG$ WHERE&lt;br /&gt;  "SNAPTIME$$" &amp;gt; :1 AND ("DMLTYPE$$" != 'D')) LOG$ WHERE CURRENT$."ID" =&lt;br /&gt;  LOG$."ID")"AV$" ON ("SNA$"."ID" = "AV$"."ID") WHEN MATCHED THEN UPDATE  SET&lt;br /&gt;  "SNA$"."ID" = "AV$"."ID","SNA$"."ITEM_NAME" = "AV$"."ITEM_NAME" WHEN NOT&lt;br /&gt;  MATCHED THEN INSERT  (SNA$."ID",SNA$."ITEM_NAME") VALUES (AV$."ID",&lt;br /&gt;  AV$."ITEM_NAME")&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Thus, it is possible to do a Fast Refresh on an MV that was defined on a Prebuilt Table.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-1197354923923376119?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/1197354923923376119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=1197354923923376119' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1197354923923376119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1197354923923376119'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2012/01/refreshing-mv-on-prebuilt-table.html' title='Refreshing an MV on a Prebuilt Table'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-6095277741056924878</id><published>2012-01-19T23:34:00.003+08:00</published><updated>2012-01-19T23:34:36.846+08:00</updated><title type='text'>SQL in Functions</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Here's an article "&lt;a href="https://sites.google.com/site/hemantswebsite/oracle-diagnostics/SQLinFunctions.pdf" target="_blank"&gt;SQL in Functions&lt;/a&gt;" &amp;nbsp;that I had submitted for publication in AIOUG's Sangam Journal in November 2010.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-6095277741056924878?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/6095277741056924878/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=6095277741056924878' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6095277741056924878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6095277741056924878'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2012/01/sql-in-functions.html' title='SQL in Functions'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-6821260940213076441</id><published>2012-01-15T23:53:00.000+08:00</published><updated>2012-01-17T23:52:33.279+08:00</updated><title type='text'>Growing Materialized View (Snapshot) Logs</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;As I had noted about 5 years ago "&lt;a href="http://hemantoracledba.blogspot.com/2007/01/large-growing-snapshot-logs-indicate.html" target="_blank"&gt;Large (Growing) Snapshot Logs indicate that you have a problem&lt;/a&gt;", if you have a Fast Refresh Materialized View that hasn't been refreshed for a considerable period of time, you will find that the Materialized View Log ("Snapshot Log" in earlier versions) would keep growing because it patiently expects the MV to come around for the next refresh.&amp;nbsp; You can end up with very large MV Logs and also performance issues inserting into the base tables as each insert also has to update the MV Logs.&amp;nbsp; Furthermore, other MVs that do refresh from the same base table may also suffer because they have to contend with larger MV Logs.&lt;br /&gt;&lt;br /&gt;Here is a demonstration with two users "ANOTHER_USR" and "LAZY_USR" having created their own Materialized Views against my source table.&amp;nbsp; If LAZY_USR does not execute a Refresh of his MV, the Snapshot Log on my source table does not get purge.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre&gt;23:39:21 SQL&amp;gt; --- create two users that will be creating MVs&lt;br /&gt;23:39:21 SQL&amp;gt; drop user another_usr cascade;&lt;br /&gt;&lt;br /&gt;User dropped.&lt;br /&gt;&lt;br /&gt;23:39:21 SQL&amp;gt; create user another_usr identified by another_usr default tablespace users;&lt;br /&gt;&lt;br /&gt;User created.&lt;br /&gt;&lt;br /&gt;23:39:21 SQL&amp;gt; grant create session, create table, create materialized view to another_usr;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;23:39:21 SQL&amp;gt; alter user another_usr quota unlimited on users;&lt;br /&gt;&lt;br /&gt;User altered.&lt;br /&gt;&lt;br /&gt;23:39:21 SQL&amp;gt; &lt;br /&gt;23:39:21 SQL&amp;gt; drop user lazy_usr cascade;&lt;br /&gt;&lt;br /&gt;User dropped.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; create user lazy_usr identified by lazy_usr default tablespace users;&lt;br /&gt;&lt;br /&gt;User created.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; grant create session, create table, create materialized view to lazy_usr;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; alter user lazy_usr quota unlimited on users;&lt;br /&gt;&lt;br /&gt;User altered.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; &lt;br /&gt;23:39:22 SQL&amp;gt; &lt;br /&gt;23:39:22 SQL&amp;gt; --- create the source table and mv log on it&lt;br /&gt;23:39:22 SQL&amp;gt; drop table my_data_table purge;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; create table my_data_table&lt;br /&gt;23:39:22   2  as select object_id as ID_Number, object_name as Data_Item, created as Crtn_date&lt;br /&gt;23:39:22   3  from dba_objects where object_id is not null;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; alter table my_data_table modify (ID_Number not null);&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; alter table my_data_table add constraint my_data_table_pk primary key (ID_Number);&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; &lt;br /&gt;23:39:22 SQL&amp;gt; create materialized view log on my_data_table ;&lt;br /&gt;&lt;br /&gt;Materialized view log created.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; &lt;br /&gt;23:39:22 SQL&amp;gt; grant select on my_data_table to another_usr;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; grant select on mlog$_my_data_table to another_usr;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; grant select on my_data_table to lazy_usr;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; grant select on mlog$_my_data_table to lazy_usr;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; &lt;br /&gt;23:39:22 SQL&amp;gt; --- create the mv in the another_usr account&lt;br /&gt;23:39:22 SQL&amp;gt; connect another_usr/another_usr&lt;br /&gt;Connected.&lt;br /&gt;23:39:22 SQL&amp;gt; create materialized view my_mv&lt;br /&gt;23:39:22   2  refresh fast on demand&lt;br /&gt;23:39:22   3  as&lt;br /&gt;23:39:22   4  select rowid as row_identifier, id_number, data_item&lt;br /&gt;23:39:22   5  from hemant.my_data_table&lt;br /&gt;23:39:22   6  /&lt;br /&gt;&lt;br /&gt;Materialized view created.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; &lt;br /&gt;23:39:22 SQL&amp;gt; --- query the data dictionary&lt;br /&gt;23:39:22 SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;23:39:22 SQL&amp;gt; col owner format a12&lt;br /&gt;23:39:22 SQL&amp;gt; col name format a12&lt;br /&gt;23:39:22 SQL&amp;gt; col snapshot_site format a12&lt;br /&gt;23:39:22 SQL&amp;gt; col refresh_method format a12&lt;br /&gt;23:39:22 SQL&amp;gt; select name from v$database;&lt;br /&gt;&lt;br /&gt;NAME                                                                            &lt;br /&gt;------------                                                                    &lt;br /&gt;ORCL                                                                            &lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; select v.owner, v.name, v.snapshot_site, v.refresh_method,&lt;br /&gt;23:39:22   2        to_char(l.current_snapshots,'DD-MON HH24:MI:SS')&lt;br /&gt;23:39:22   3  from dba_registered_snapshots v, dba_snapshot_logs l&lt;br /&gt;23:39:22   4  where v.snapshot_id = l.snapshot_id&lt;br /&gt;23:39:22   5  and l.log_owner = 'HEMANT'&lt;br /&gt;23:39:22   6  and l.master = 'MY_DATA_TABLE'&lt;br /&gt;23:39:22   7  order by 1,2&lt;br /&gt;23:39:22   8  /&lt;br /&gt;&lt;br /&gt;OWNER        NAME         SNAPSHOT_SIT REFRESH_METH TO_CHAR(L.CURRENT_SNAPSH    &lt;br /&gt;------------ ------------ ------------ ------------ ------------------------    &lt;br /&gt;ANOTHER_USR  MY_MV        ORCL         PRIMARY KEY  15-JAN 23:39:23             &lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; &lt;br /&gt;23:39:22 SQL&amp;gt; -- insert into the source table&lt;br /&gt;23:39:22 SQL&amp;gt; insert into my_data_table values (1000000,'A DUMMY',sysdate);&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; &lt;br /&gt;23:39:22 SQL&amp;gt; select count(*) from mlog$_my_data_table;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         1                                                                      &lt;br /&gt;&lt;br /&gt;23:39:22 SQL&amp;gt; &lt;br /&gt;23:39:22 SQL&amp;gt; exec dbms_lock.sleep(30);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:39:52 SQL&amp;gt; &lt;br /&gt;23:39:52 SQL&amp;gt; --- check if the MV has been updated ?!&lt;br /&gt;23:39:52 SQL&amp;gt; select v.owner, v.name, v.snapshot_site, v.refresh_method,&lt;br /&gt;23:39:52   2        to_char(l.current_snapshots,'DD-MON HH24:MI:SS')&lt;br /&gt;23:39:52   3  from dba_registered_snapshots v, dba_snapshot_logs l&lt;br /&gt;23:39:52   4  where v.snapshot_id = l.snapshot_id&lt;br /&gt;23:39:52   5  and l.log_owner = 'HEMANT'&lt;br /&gt;23:39:52   6  and l.master = 'MY_DATA_TABLE'&lt;br /&gt;23:39:52   7  order by 1,2&lt;br /&gt;23:39:52   8  /&lt;br /&gt;&lt;br /&gt;OWNER        NAME         SNAPSHOT_SIT REFRESH_METH TO_CHAR(L.CURRENT_SNAPSH    &lt;br /&gt;------------ ------------ ------------ ------------ ------------------------    &lt;br /&gt;ANOTHER_USR  MY_MV        ORCL         PRIMARY KEY  15-JAN 23:39:23             &lt;br /&gt;&lt;br /&gt;23:39:52 SQL&amp;gt; &lt;br /&gt;23:39:52 SQL&amp;gt; exec dbms_lock.sleep(10);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:40:02 SQL&amp;gt; &lt;br /&gt;23:40:02 SQL&amp;gt; -- refresh the MV&lt;br /&gt;23:40:02 SQL&amp;gt; connect another_usr/another_usr&lt;br /&gt;Connected.&lt;br /&gt;23:40:03 SQL&amp;gt; exec dbms_mview.refresh('MY_MV');&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:40:03 SQL&amp;gt; &lt;br /&gt;23:40:03 SQL&amp;gt; &lt;br /&gt;23:40:03 SQL&amp;gt; --- re-query the data dictionary&lt;br /&gt;23:40:03 SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;23:40:03 SQL&amp;gt; select v.owner, v.name, v.snapshot_site, v.refresh_method,&lt;br /&gt;23:40:03   2        to_char(l.current_snapshots,'DD-MON HH24:MI:SS')&lt;br /&gt;23:40:03   3  from dba_registered_snapshots v, dba_snapshot_logs l&lt;br /&gt;23:40:03   4  where v.snapshot_id = l.snapshot_id&lt;br /&gt;23:40:03   5  and l.log_owner = 'HEMANT'&lt;br /&gt;23:40:03   6  and l.master = 'MY_DATA_TABLE'&lt;br /&gt;23:40:03   7  order by 1,2&lt;br /&gt;23:40:03   8  /&lt;br /&gt;&lt;br /&gt;OWNER        NAME         SNAPSHOT_SIT REFRESH_METH TO_CHAR(L.CURRENT_SNAPSH    &lt;br /&gt;------------ ------------ ------------ ------------ ------------------------    &lt;br /&gt;ANOTHER_USR  MY_MV        ORCL         PRIMARY KEY  15-JAN 23:40:03             &lt;br /&gt;&lt;br /&gt;23:40:03 SQL&amp;gt; select count(*) from mlog$_my_data_table;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         0                                                                      &lt;br /&gt;&lt;br /&gt;23:40:03 SQL&amp;gt; &lt;br /&gt;23:40:03 SQL&amp;gt; --- create another mv in the lazy_usr account&lt;br /&gt;23:40:03 SQL&amp;gt; connect lazy_usr/lazy_usr&lt;br /&gt;Connected.&lt;br /&gt;23:40:03 SQL&amp;gt; create materialized view lazy_mv&lt;br /&gt;23:40:03   2  refresh fast on demand&lt;br /&gt;23:40:03   3  as&lt;br /&gt;23:40:03   4  select rowid as row_identifier, id_number, data_item&lt;br /&gt;23:40:03   5  from hemant.my_data_table&lt;br /&gt;23:40:03   6  /&lt;br /&gt;&lt;br /&gt;Materialized view created.&lt;br /&gt;&lt;br /&gt;23:40:03 SQL&amp;gt; &lt;br /&gt;23:40:03 SQL&amp;gt; &lt;br /&gt;23:40:03 SQL&amp;gt; --- insert new data&lt;br /&gt;23:40:03 SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;23:40:03 SQL&amp;gt; insert into my_data_table values (2000000,'Another dummy',sysdate);&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;23:40:03 SQL&amp;gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;23:40:03 SQL&amp;gt; select count(*) from mlog$_my_data_table;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         1                                                                      &lt;br /&gt;&lt;br /&gt;23:40:03 SQL&amp;gt; &lt;br /&gt;23:40:03 SQL&amp;gt; exec dbms_lock.sleep(30);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:40:33 SQL&amp;gt; &lt;br /&gt;23:40:33 SQL&amp;gt; -- refresh another_usr's mv only&lt;br /&gt;23:40:33 SQL&amp;gt; connect another_usr/another_usr&lt;br /&gt;Connected.&lt;br /&gt;23:40:33 SQL&amp;gt; exec dbms_mview.refresh('MY_MV');&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:40:34 SQL&amp;gt; &lt;br /&gt;23:40:34 SQL&amp;gt; --- requery the data dictionary&lt;br /&gt;23:40:34 SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;23:40:34 SQL&amp;gt; select v.owner, v.name, v.snapshot_site, v.refresh_method,&lt;br /&gt;23:40:34   2        to_char(l.current_snapshots,'DD-MON HH24:MI:SS')&lt;br /&gt;23:40:34   3  from dba_registered_snapshots v, dba_snapshot_logs l&lt;br /&gt;23:40:34   4  where v.snapshot_id = l.snapshot_id&lt;br /&gt;23:40:34   5  and l.log_owner = 'HEMANT'&lt;br /&gt;23:40:34   6  and l.master = 'MY_DATA_TABLE'&lt;br /&gt;23:40:34   7  order by 1,2&lt;br /&gt;23:40:34   8  /&lt;br /&gt;&lt;br /&gt;OWNER        NAME         SNAPSHOT_SIT REFRESH_METH TO_CHAR(L.CURRENT_SNAPSH    &lt;br /&gt;------------ ------------ ------------ ------------ ------------------------    &lt;br /&gt;ANOTHER_USR  MY_MV        ORCL         PRIMARY KEY  15-JAN 23:40:34             &lt;br /&gt;LAZY_USR     LAZY_MV      ORCL         PRIMARY KEY  15-JAN 23:40:04             &lt;br /&gt;&lt;br /&gt;23:40:34 SQL&amp;gt; select count(*) from mlog$_my_data_table;&lt;br /&gt;&lt;br /&gt;  COUNT(*)                                                                      &lt;br /&gt;----------                                                                      &lt;br /&gt;         1                                                                      &lt;br /&gt;&lt;br /&gt;23:40:34 SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;My data dictionary query, at the first execution at 23:39:22, showed that ANOTHER_USR had an MV called "MY_MV" against my table MY_DATA_TABLE.&amp;nbsp; Inserting a single row in MY_DATA_TABLE caused a corresponding row to be inserted into the MV Log MLOG$_MY_DATA_TABLE.&amp;nbsp; However, as ANOTHER_USR had not refreshed his MV even as at 23:39:52, the Data Dictionary showed that the MV was still as of 23:39:23.&lt;br /&gt;After ANOTHER_USR did refresh his MV (at 23:40:03), the MV Log MLOG$_MY_DATA_TABLE was purged of the record that was used to track the one row DML against MY_DATA_TABLE.&lt;br /&gt;&lt;br /&gt;However, when LAZY_USR created an MV but did not refresh the MV, even as at 23:40:34, the one row in MLOG$_MY_DATA_TABLE&amp;nbsp; (to capture the insert of "(2000000,'Another dummy',sysdate)), was *not* purged.&amp;nbsp; Until LAZY_USR executes a Refresh of his MV,&amp;nbsp; MLOG$_MY_DATA_TABLE will keep growing, even though ANOTHER_USR might be diligently refreshing his MV.&lt;br /&gt;Over time, I will find MLOG$_MY_DATA_TABLE to have grown "excessively large !".&lt;br /&gt;&lt;br /&gt;The solution is to identify LAZY_USR (which the query against the Data Dictionary does do) and then :&lt;br /&gt;0&amp;nbsp; (optional).&amp;nbsp; Drop LAZY_USR's MV "LAZY_MV"&lt;br /&gt;2.&amp;nbsp; Purge MLOG$_MY_DATA_TABLE (using either DBMS_MVIEW.PURGE_LOG or a TRUNCATE)&lt;br /&gt;3.&amp;nbsp; ReCreate or Refersh LAZY_USR's MV "LAZY_MV"&lt;br /&gt;&lt;br /&gt;I have seen situations where LAZY_USR is a an account in a "remote" database managed by another application / development / support / DBA team that doesn't bother to inform HEMANT that they are no longer refreshing the MV even as HEMANT's schema continues to grow only to hold entries in MLOG$_MY_DATA_TABLE.&amp;nbsp; &lt;br /&gt;The example I have posted is of 1 source table and 1 row DML.&amp;nbsp; In real-life you may have a dozen such tables and tens of thousands of rows before you notice this (and you would notice it only if you are diligently monitoring all the schemas in your database).&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-6821260940213076441?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/6821260940213076441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=6821260940213076441' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6821260940213076441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6821260940213076441'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2012/01/growing-materialized-view-snapshot-logs.html' title='Growing Materialized View (Snapshot) Logs'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-8863356365124819738</id><published>2012-01-01T12:13:00.001+08:00</published><updated>2012-01-01T12:13:52.667+08:00</updated><title type='text'>Datafiles not Restored  -- using V$DATAFILE and V$DATAFILE_HEADER</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Building on my previous blog post "&lt;a href="http://hemantoracledba.blogspot.com/2011/12/does-startup-mount-verify-datafiles.html" target="_blank"&gt;Does a STARTUP MOUNT verify datafiles ?&lt;/a&gt;",&amp;nbsp; here's how I can use the V$DATAFILE and V$DATAFILE_HEADER views from the controlfile to identify datafiles that are / are not restored.&amp;nbsp; This is a case where I have to do a FULL Restore.&lt;br /&gt;&lt;br /&gt;I first restore the controlfile :&lt;/div&gt;&lt;pre&gt;MAN&amp;gt; startup nomount;&lt;br /&gt;&lt;br /&gt;connected to target database (not started)&lt;br /&gt;Oracle instance started&lt;br /&gt;&lt;br /&gt;Total System Global Area     313860096 bytes&lt;br /&gt;&lt;br /&gt;Fixed Size                     1336232 bytes&lt;br /&gt;Variable Size                281021528 bytes&lt;br /&gt;Database Buffers              25165824 bytes&lt;br /&gt;Redo Buffers                   6336512 bytes&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; restore controlfile from autobackup;&lt;br /&gt;&lt;br /&gt;Starting restore at 01-JAN-12&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=192 device type=DISK&lt;br /&gt;&lt;br /&gt;recovery area destination: /home/oracle/app/oracle/flash_recovery_area&lt;br /&gt;database name (or database unique name) used for search: ORCL&lt;br /&gt;channel ORA_DISK_1: AUTOBACKUP /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_01_01/o1_mf_n_771420416_7hznn10m_.bkp found in the recovery area&lt;br /&gt;channel ORA_DISK_1: looking for AUTOBACKUP on day: 20120101&lt;br /&gt;channel ORA_DISK_1: restoring control file from AUTOBACKUP /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_01_01/o1_mf_n_771420416_7hznn10m_.bkp&lt;br /&gt;channel ORA_DISK_1: control file restore from AUTOBACKUP complete&lt;br /&gt;output file name=/home/oracle/app/oracle/oradata/orcl/control01.ctl&lt;br /&gt;output file name=/home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl&lt;br /&gt;Finished restore at 01-JAN-12&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; &lt;br /&gt;RMAN&amp;gt; alter database mount;&lt;br /&gt;&lt;br /&gt;database mounted&lt;br /&gt;released channel: ORA_DISK_1&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; exit&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Recovery Manager complete.&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;I then query the V$DATAFILE and V$DATAFILE_HEADER views.   Remember : There are NO datafiles present on this server.  I only have the controlfile.  I find (see the output below) that V$DATAFILE shows all the files expected to be present but V$DATAFILE_HEADER does not find any files.&lt;/div&gt;&lt;pre&gt;oracle@linux64 ~]$ sqlplus '/ as sysdba'&lt;br /&gt;&lt;br /&gt;SQL*Plus: Release 11.2.0.1.0 Production on Sun Jan 1 11:34:25 2012&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle.  All rights reserved.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Connected to:&lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production&lt;br /&gt;With the Partitioning, OLAP, Data Mining and Real Application Testing options&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; set pages600       &lt;br /&gt;SQL&amp;gt; select file#, name from v$datafile order by 1;&lt;br /&gt;&lt;br /&gt;     FILE#&lt;br /&gt;----------&lt;br /&gt;NAME&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;         1&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;&lt;br /&gt;         2&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf&lt;br /&gt;&lt;br /&gt;         3&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf&lt;br /&gt;&lt;br /&gt;         4&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/users01.dbf&lt;br /&gt;&lt;br /&gt;         5&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/example01.dbf&lt;br /&gt;&lt;br /&gt;         6&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/FLOW_1046101119510758.dbf&lt;br /&gt;&lt;br /&gt;         7&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/FLOW_1146416395631714.dbf&lt;br /&gt;&lt;br /&gt;         8&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/FLOW_1170420963682633.dbf&lt;br /&gt;&lt;br /&gt;         9&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/FLOW_1194425963955800.dbf&lt;br /&gt;&lt;br /&gt;        10&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/FLOW_1218408858999342.dbf&lt;br /&gt;&lt;br /&gt;        11&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/FLOW_1242310449730067.dbf&lt;br /&gt;&lt;br /&gt;        12&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/FLOW_1266412439758696.dbf&lt;br /&gt;&lt;br /&gt;        13&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/APEX_1295922881855015.dbf&lt;br /&gt;&lt;br /&gt;        14&lt;br /&gt;/oradata/add_tbs.dbf&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;14 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; select file#, name from v$datafile_header order by 1;&lt;br /&gt;&lt;br /&gt;     FILE#&lt;br /&gt;----------&lt;br /&gt;NAME&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;         1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         3&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         4&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         5&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         6&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         7&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         8&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         9&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        10&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        11&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        12&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        13&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        14&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;14 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; select file#, nvl(name,'File Not Found') from v$datafile_header order by 1;&lt;br /&gt;&lt;br /&gt;     FILE#&lt;br /&gt;----------&lt;br /&gt;NVL(NAME,'FILENOTFOUND')&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;         1&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;         2&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;         3&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;         4&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;         5&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;         6&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;         7&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;         8&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;         9&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;        10&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;        11&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;        12&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;        13&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;        14&lt;br /&gt;File Not Found&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;14 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; exit&lt;br /&gt;&lt;/pre&gt;Thus, all 14 entries are present in V$DATAFILE_HEADER but with a NULL NAME.&lt;br /&gt;&lt;br /&gt;I then begin a RESTORE :&lt;/div&gt;&lt;pre&gt;[oracle@linux64 ~]$ rman target /&lt;br /&gt;&lt;br /&gt;Recovery Manager: Release 11.2.0.1.0 - Production on Sun Jan 1 11:36:07 2012&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.&lt;br /&gt;&lt;br /&gt;connected to target database: ORCL (DBID=1229390655, not open)&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; &lt;br /&gt;RMAN&amp;gt; restore database;&lt;br /&gt;&lt;br /&gt;Starting restore at 01-JAN-12&lt;br /&gt;Starting implicit crosscheck backup at 01-JAN-12&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=192 device type=DISK&lt;br /&gt;Crosschecked 12 objects&lt;br /&gt;Finished implicit crosscheck backup at 01-JAN-12&lt;br /&gt;&lt;br /&gt;Starting implicit crosscheck copy at 01-JAN-12&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;Finished implicit crosscheck copy at 01-JAN-12&lt;br /&gt;&lt;br /&gt;searching for all files in the recovery area&lt;br /&gt;cataloging files...&lt;br /&gt;cataloging done&lt;br /&gt;&lt;br /&gt;List of Cataloged Files&lt;br /&gt;=======================&lt;br /&gt;File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_01_01/o1_mf_n_771420416_7hznn10m_.bkp&lt;br /&gt;&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00014 to /oradata/add_tbs.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp&lt;br /&gt;channel ORA_DISK_1: ORA-19870: error while restoring backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp&lt;br /&gt;ORA-19504: failed to create file "/oradata/add_tbs.dbf"&lt;br /&gt;ORA-27037: unable to obtain file status&lt;br /&gt;Linux Error: 13: Permission denied&lt;br /&gt;Additional information: 6&lt;br /&gt;&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00004 to /home/oracle/app/oracle/oradata/orcl/users01.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00007 to /home/oracle/app/oracle/oradata/orcl/FLOW_1146416395631714.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznm84k_.bkp&lt;br /&gt;channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznm84k_.bkp tag=TAG20120101T112516&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:00:15&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/app/oracle/oradata/orcl/example01.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00006 to /home/oracle/app/oracle/oradata/orcl/FLOW_1046101119510758.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00008 to /home/oracle/app/oracle/oradata/orcl/FLOW_1170420963682633.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznmq8q_.bkp&lt;br /&gt;channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznmq8q_.bkp tag=TAG20120101T112516&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:00:07&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00009 to /home/oracle/app/oracle/oradata/orcl/FLOW_1194425963955800.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00010 to /home/oracle/app/oracle/oradata/orcl/FLOW_1218408858999342.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00011 to /home/oracle/app/oracle/oradata/orcl/FLOW_1242310449730067.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00012 to /home/oracle/app/oracle/oradata/orcl/FLOW_1266412439758696.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00013 to /home/oracle/app/oracle/oradata/orcl/APEX_1295922881855015.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznmydw_.bkp&lt;br /&gt;channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznmydw_.bkp tag=TAG20120101T112516&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:00:01&lt;br /&gt;failover to previous backup&lt;br /&gt;&lt;br /&gt;creating datafile file number=14 name=/oradata/add_tbs.dbf&lt;br /&gt;RMAN-00571: ===========================================================&lt;br /&gt;RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============&lt;br /&gt;RMAN-00571: ===========================================================&lt;br /&gt;RMAN-03002: failure of restore command at 01/01/2012 11:36:45&lt;br /&gt;ORA-01119: error in creating database file '/oradata/add_tbs.dbf'&lt;br /&gt;ORA-27037: unable to obtain file status&lt;br /&gt;Linux Error: 13: Permission denied&lt;br /&gt;Additional information: 6&lt;br /&gt;RMAN-06956: create datafile failed; retry after removing /oradata/add_tbs.dbf from OS&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; &lt;br /&gt;RMAN&amp;gt; restore database;&lt;br /&gt;&lt;br /&gt;Starting restore at 01-JAN-12&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;&lt;br /&gt;skipping datafile 4; already restored to file /home/oracle/app/oracle/oradata/orcl/users01.dbf&lt;br /&gt;skipping datafile 7; already restored to file /home/oracle/app/oracle/oradata/orcl/FLOW_1146416395631714.dbf&lt;br /&gt;skipping datafile 5; already restored to file /home/oracle/app/oracle/oradata/orcl/example01.dbf&lt;br /&gt;skipping datafile 6; already restored to file /home/oracle/app/oracle/oradata/orcl/FLOW_1046101119510758.dbf&lt;br /&gt;skipping datafile 8; already restored to file /home/oracle/app/oracle/oradata/orcl/FLOW_1170420963682633.dbf&lt;br /&gt;skipping datafile 9; already restored to file /home/oracle/app/oracle/oradata/orcl/FLOW_1194425963955800.dbf&lt;br /&gt;skipping datafile 10; already restored to file /home/oracle/app/oracle/oradata/orcl/FLOW_1218408858999342.dbf&lt;br /&gt;skipping datafile 11; already restored to file /home/oracle/app/oracle/oradata/orcl/FLOW_1242310449730067.dbf&lt;br /&gt;skipping datafile 12; already restored to file /home/oracle/app/oracle/oradata/orcl/FLOW_1266412439758696.dbf&lt;br /&gt;skipping datafile 13; already restored to file /home/oracle/app/oracle/oradata/orcl/APEX_1295922881855015.dbf&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00014 to /oradata/add_tbs.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp&lt;br /&gt;channel ORA_DISK_1: ORA-19870: error while restoring backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp&lt;br /&gt;ORA-19504: failed to create file "/oradata/add_tbs.dbf"&lt;br /&gt;ORA-27037: unable to obtain file status&lt;br /&gt;Linux Error: 13: Permission denied&lt;br /&gt;Additional information: 6&lt;br /&gt;&lt;br /&gt;failover to previous backup&lt;br /&gt;&lt;br /&gt;creating datafile file number=14 name=/oradata/add_tbs.dbf&lt;br /&gt;RMAN-00571: ===========================================================&lt;br /&gt;RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============&lt;br /&gt;RMAN-00571: ===========================================================&lt;br /&gt;RMAN-03002: failure of restore command at 01/01/2012 11:37:42&lt;br /&gt;ORA-01119: error in creating database file '/oradata/add_tbs.dbf'&lt;br /&gt;ORA-27037: unable to obtain file status&lt;br /&gt;Linux Error: 13: Permission denied&lt;br /&gt;Additional information: 6&lt;br /&gt;RMAN-06956: create datafile failed; retry after removing /oradata/add_tbs.dbf from OS&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; &lt;br /&gt;RMAN&amp;gt; exit&lt;br /&gt;&lt;/pre&gt;I get an OS permissions error for File #14 ('/oradata/add_tbs.dbf')  because oracle does not have write permissions for this directory path on this server !&amp;nbsp; Very unfortunately, RMAN isn't currently intelligent enough to skip this one file and restore the other files from the same backuppiece.  Apparently, all 4 files in the backup piece are not restored !&lt;br /&gt;RMAN does skip over datafiles 4 to 13 that have already been restored and does not attempt to restore these files at the second RESTORE execution.&lt;br /&gt;Before attempting to restore these 4 files, I also use the V$DATAFILE and V$DATAFILE_HEADER views to identify them :&lt;/div&gt;&lt;pre&gt;oracle@linux64 ~]$ sqlplus '/ as sysdba'&lt;br /&gt;&lt;br /&gt;SQL*Plus: Release 11.2.0.1.0 Production on Sun Jan 1 11:42:06 2012&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle.  All rights reserved.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Connected to:&lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production&lt;br /&gt;With the Partitioning, OLAP, Data Mining and Real Application Testing options&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; set pages600&lt;br /&gt;SQL&amp;gt; select file#, name from v$datafile&lt;br /&gt;  2  minus&lt;br /&gt;  3  select file#, name from v$datafile_header&lt;br /&gt;  4  order by 1;&lt;br /&gt;&lt;br /&gt;     FILE#&lt;br /&gt;----------&lt;br /&gt;NAME&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;         1&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;&lt;br /&gt;         2&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf&lt;br /&gt;&lt;br /&gt;         3&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf&lt;br /&gt;&lt;br /&gt;        14&lt;br /&gt;/oradata/add_tbs.dbf&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; exit&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;I then RESTORE the 4 files individually :&lt;/div&gt;&lt;pre&gt;[oracle@linux64 ~]$ rman target /&lt;br /&gt;&lt;br /&gt;Recovery Manager: Release 11.2.0.1.0 - Production on Sun Jan 1 11:42:52 2012&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.&lt;br /&gt;&lt;br /&gt;connected to target database: ORCL (DBID=1229390655, not open)&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; restore datafile 1;&lt;br /&gt;&lt;br /&gt;Starting restore at 01-JAN-12&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=192 device type=DISK&lt;br /&gt;&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp&lt;br /&gt;channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp tag=TAG20120101T112516&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:01:15&lt;br /&gt;Finished restore at 01-JAN-12&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; restore datafile 2;&lt;br /&gt;&lt;br /&gt;Starting restore at 01-JAN-12&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp&lt;br /&gt;channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp tag=TAG20120101T112516&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:01:15&lt;br /&gt;Finished restore at 01-JAN-12&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; restore datafile 3;&lt;br /&gt;&lt;br /&gt;Starting restore at 01-JAN-12&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp&lt;br /&gt;channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp tag=TAG20120101T112516&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:00:15&lt;br /&gt;Finished restore at 01-JAN-12&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; run&lt;br /&gt;2&amp;gt; {set newname for datafile 14 to '/home/oracle/app/oracle/oradata/orcl/add_tbs.dbf';&lt;br /&gt;3&amp;gt; restore datafile 14;&lt;br /&gt;4&amp;gt; }&lt;br /&gt;&lt;br /&gt;executing command: SET NEWNAME&lt;br /&gt;&lt;br /&gt;Starting restore at 01-JAN-12&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00014 to /home/oracle/app/oracle/oradata/orcl/add_tbs.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp&lt;br /&gt;channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp tag=TAG20120101T112516&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:00:03&lt;br /&gt;Finished restore at 01-JAN-12&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; &lt;br /&gt;&lt;/pre&gt;However, since I have used a NEWNAME for datafile #14, I must SWITCH it before I can use RECOVER DATABASE :&lt;/div&gt;&lt;pre&gt;RMAN&amp;gt; recover database; &lt;br /&gt;&lt;br /&gt;Starting recover at 01-JAN-12&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;RMAN-00571: ===========================================================&lt;br /&gt;RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============&lt;br /&gt;RMAN-00571: ===========================================================&lt;br /&gt;RMAN-03002: failure of recover command at 01/01/2012 11:48:44&lt;br /&gt;RMAN-06094: datafile 14 must be restored&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; switch datafile 14 to copy;&lt;br /&gt;&lt;br /&gt;datafile 14 switched to datafile copy "/home/oracle/app/oracle/oradata/orcl/add_tbs.dbf"&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; recover database;&lt;br /&gt;&lt;br /&gt;Starting recover at 01-JAN-12&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;&lt;br /&gt;starting media recovery&lt;br /&gt;&lt;br /&gt;archived log for thread 1 with sequence 2 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_01_01/o1_mf_1_2_7hznmzh7_.arc&lt;br /&gt;archived log for thread 1 with sequence 3 is already on disk as file /home/oracle/app/oracle/oradata/orcl/redo03.log&lt;br /&gt;archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_01_01/o1_mf_1_2_7hznmzh7_.arc thread=1 sequence=2&lt;br /&gt;archived log file name=/home/oracle/app/oracle/oradata/orcl/redo03.log thread=1 sequence=3&lt;br /&gt;media recovery complete, elapsed time: 00:00:00&lt;br /&gt;Finished recover at 01-JAN-12&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; &lt;br /&gt;RMAN&amp;gt; exit&lt;br /&gt;&lt;/pre&gt;I now verify the datafiles again, before actually OPENing the database :&lt;/div&gt;&lt;pre&gt;[oracle@linux64 ~]$ sqlplus&lt;br /&gt;&lt;br /&gt;SQL*Plus: Release 11.2.0.1.0 Production on Sun Jan 1 11:51:23 2012&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle.  All rights reserved.&lt;br /&gt;&lt;br /&gt;Enter user-name: / as sysdba&lt;br /&gt;&lt;br /&gt;Connected to:&lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production&lt;br /&gt;With the Partitioning, OLAP, Data Mining and Real Application Testing options&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select file#, name from v$datafile&lt;br /&gt;  2  minus&lt;br /&gt;  3  select file#, name from v$datafile_header&lt;br /&gt;  4  order by 1;&lt;br /&gt;&lt;br /&gt;no rows selected&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select name from v$datafile where file#=14;&lt;br /&gt;&lt;br /&gt;NAME&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/add_tbs.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter database open resetlogs;&lt;br /&gt;&lt;br /&gt;Database altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;Now it should be clear how V$DATAFILE and V$DATAFILE_HEADER are different.  V$DATAFILE_HEADER does actually verify the datafile, while V$DATAFILE only reads the controlfile.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-8863356365124819738?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/8863356365124819738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=8863356365124819738' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/8863356365124819738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/8863356365124819738'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2012/01/datafiles-not-restored-using-vdatafile.html' title='Datafiles not Restored  -- using V$DATAFILE and V$DATAFILE_HEADER'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7533910766586328833</id><published>2011-12-29T00:26:00.003+08:00</published><updated>2011-12-29T00:28:27.405+08:00</updated><title type='text'>Does a STARTUP MOUNT verify datafiles ?</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;There seems to be a misunderstanding that a MOUNT actually verifies datafiles.&lt;br /&gt;A STARTUP MOUNT &amp;nbsp;(or STARTUP NOMOUNT followed by ALTER DATABASE MOUNT) does *NOT* read the datafiles and/or verify them. &amp;nbsp;It does read the controlfile(s).&lt;br /&gt;&lt;br /&gt;Here's a simple test :&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;I have a tablespace with a datafile that is "ONLINE".&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; create tablespace X_TBS datafile '/tmp/X_TBS.dbf' size 50M;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create table hemant.X_TBS (col_1) tablespace X_TBS&lt;br /&gt;  2  as select rownum from dual connect by level &amp;lt; 100;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select file#, status, name &lt;br /&gt;  2  from v$datafile&lt;br /&gt;  3  where name like '%X_TBS%';&lt;br /&gt;&lt;br /&gt;     FILE# STATUS  NAME&lt;br /&gt;---------- ------- ----------------------------------------&lt;br /&gt;        14 ONLINE  /tmp/X_TBS.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select file#, status, name&lt;br /&gt;  2  from v$datafile_header&lt;br /&gt;  3  where name like '%X_TBS%';&lt;br /&gt;&lt;br /&gt;     FILE# STATUS  NAME&lt;br /&gt;---------- ------- ----------------------------------------&lt;br /&gt;        14 ONLINE  /tmp/X_TBS.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select owner, segment_name, bytes/1024&lt;br /&gt;  2  from dba_segments&lt;br /&gt;  3  where tablespace_name = 'X_TBS';&lt;br /&gt;&lt;br /&gt;OWNER&lt;br /&gt;------------------------------&lt;br /&gt;SEGMENT_NAME&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;BYTES/1024&lt;br /&gt;----------&lt;br /&gt;HEMANT&lt;br /&gt;X_TBS&lt;br /&gt;        64&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;I now shutdown the database instance and remove the datafile :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; shutdown immediate&lt;br /&gt;Database closed.&lt;br /&gt;Database dismounted.&lt;br /&gt;ORACLE instance shut down.&lt;br /&gt;SQL&amp;gt; !ls /tmp/X_TBS.dbf&lt;br /&gt;/tmp/X_TBS.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; !rm /tmp/X_TBS.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; !ls /tmp/X_TBS.dbf&lt;br /&gt;ls: /tmp/X_TBS.dbf: No such file or directory&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;Does the STARTUP MOUNT succeed ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; startup mount&lt;br /&gt;ORACLE instance started.&lt;br /&gt;&lt;br /&gt;Total System Global Area  535662592 bytes&lt;br /&gt;Fixed Size                  1337720 bytes&lt;br /&gt;Variable Size             213911176 bytes&lt;br /&gt;Database Buffers          314572800 bytes&lt;br /&gt;Redo Buffers                5840896 bytes&lt;br /&gt;Database mounted.&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; shutdown&lt;br /&gt;ORA-01109: database not open&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Database dismounted.&lt;br /&gt;ORACLE instance shut down.&lt;br /&gt;SQL&amp;gt; startup nomount;&lt;br /&gt;ORACLE instance started.&lt;br /&gt;&lt;br /&gt;Total System Global Area  535662592 bytes&lt;br /&gt;Fixed Size                  1337720 bytes&lt;br /&gt;Variable Size             213911176 bytes&lt;br /&gt;Database Buffers          314572800 bytes&lt;br /&gt;Redo Buffers                5840896 bytes&lt;br /&gt;SQL&amp;gt; alter database mount;&lt;br /&gt;&lt;br /&gt;Database altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;Can the file be listed ?  Yes.  However, V$DATAFILE_HEADER no longer shows the name ! The query on V$DATAFILE_HEADER does cause Oracle to "look" for the file but it does NOT cause a failure.  It simply finds it "missing".&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select file#, status, name&lt;br /&gt;  2  from v$datafile&lt;br /&gt;  3  where file#=14;&lt;br /&gt;&lt;br /&gt;     FILE# STATUS  NAME&lt;br /&gt;---------- ------- ----------------------------------------&lt;br /&gt;        14 ONLINE  /tmp/X_TBS.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select file#, status, name&lt;br /&gt;  2  from v$datafile_header&lt;br /&gt;  3  where file#=14;&lt;br /&gt;&lt;br /&gt;     FILE# STATUS  NAME&lt;br /&gt;---------- ------- ----------------------------------------&lt;br /&gt;        14 ONLINE&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;When does Oracle attempt to access the datafile ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; alter database open;&lt;br /&gt;alter database open&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-01157: cannot identify/lock data file 14 - see DBWR trace file&lt;br /&gt;ORA-01110: data file 14: '/tmp/X_TBS.dbf'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;Even as the OPEN failed with an ORA-01157, the datafile is present in the controlfile :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select file#, status, name&lt;br /&gt;  2  from v$datafile&lt;br /&gt;  3  where file#=14;&lt;br /&gt;&lt;br /&gt;     FILE# STATUS  NAME&lt;br /&gt;---------- ------- ----------------------------------------&lt;br /&gt;        14 ONLINE  /tmp/X_TBS.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select file#, status, name&lt;br /&gt;  2  from v$datafile_header&lt;br /&gt;  3  where file#=14;&lt;br /&gt;&lt;br /&gt;     FILE# STATUS  NAME&lt;br /&gt;---------- ------- ----------------------------------------&lt;br /&gt;        14 ONLINE&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;I hope that I have you convinced that &lt;b&gt;a MOUNT does NOT verify the datafiles&lt;/b&gt;.If you are still not convinced, read the Backup and Recovery documentation about how to do a FULL DATABASE RESTORE and RECOVER -- where you restore the controlfile and mount the database before you even restore datafiles.  How would the MOUNT succeed with the controlfile alone ?&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;Now, here's something more.  You'd understand this if you understand how RECOVER works.  Do NOT try this if you are not sure about how I was able to "recreate" the datafile.  Do NOT try this if you do not know how data is inserted in the X_TBS table when the database is in NOARCHIVELOG mode.&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; alter database create datafile 14 as '/tmp/new_X_TBS.dbf';&lt;br /&gt;&lt;br /&gt;Database altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; recover datafile 14;&lt;br /&gt;Media recovery complete.&lt;br /&gt;SQL&amp;gt; select file#, status, name&lt;br /&gt;  2  from v$datafile&lt;br /&gt;  3  where file#=14;&lt;br /&gt;&lt;br /&gt;     FILE# STATUS  NAME&lt;br /&gt;---------- ------- ----------------------------------------&lt;br /&gt;        14 ONLINE  /tmp/new_X_TBS.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select file#, status, name&lt;br /&gt;  2  from v$datafile_header&lt;br /&gt;  3  where file#=14;&lt;br /&gt;&lt;br /&gt;     FILE# STATUS  NAME&lt;br /&gt;---------- ------- ----------------------------------------&lt;br /&gt;        14 ONLINE  /tmp/new_X_TBS.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter database open;&lt;br /&gt;&lt;br /&gt;Database altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select tablespace_name from dba_tables&lt;br /&gt;  2  where owner = 'HEMANT'&lt;br /&gt;  3  and table_name = 'X_TBS';&lt;br /&gt;&lt;br /&gt;TABLESPACE_NAME&lt;br /&gt;------------------------------&lt;br /&gt;X_TBS&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; select file_name from dba_data_files&lt;br /&gt;  2  where file_id=14;&lt;br /&gt;&lt;br /&gt;FILE_NAME&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;/tmp/new_X_TBS.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select count(*) from hemant.X_TBS;&lt;br /&gt;select count(*) from hemant.X_TBS&lt;br /&gt;                            *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-01578: ORACLE data block corrupted (file # 14, block # 131)&lt;br /&gt;ORA-01110: data file 14: '/tmp/new_X_TBS.dbf'&lt;br /&gt;ORA-26040: Data block was loaded using the NOLOGGING option&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Happy simulating and testing on your own database.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7533910766586328833?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7533910766586328833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7533910766586328833' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7533910766586328833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7533910766586328833'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/12/does-startup-mount-verify-datafiles.html' title='Does a STARTUP MOUNT verify datafiles ?'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7583821559406410224</id><published>2011-12-26T22:31:00.002+08:00</published><updated>2011-12-26T22:31:56.260+08:00</updated><title type='text'>DROP TABLESPACE INCLUDING CONTENTS drops segments</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;As reported in a few posts earlier,&amp;nbsp; DDLs always commit when beginning execution, even if they subsequently fail execution.&lt;br /&gt;Here is a demonstration of a DROP TABLESPACE INCLUDING CONTENTS&amp;nbsp; causing segments in the tablespace to be dropped even if the DROP TABLESPACE fails.&amp;nbsp; Furthermore, segments dropped by a DROP TABLESPACE are no longer in the recyclebin !&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; create tablespace TBS_2_DROP datafile '/tmp/tbs_2_drop.dbf' size 100M ;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; -- create table and populate it&lt;br /&gt;SQL&amp;gt; create table TABLE_IN_TBS_2_DROP  (col_1 number, col_2 char(50))&lt;br /&gt;  2  tablespace TBS_2_DROP&lt;br /&gt;  3  /&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; insert into TABLE_IN_TBS_2_DROP&lt;br /&gt;  2  select rownum, to_char(rownum)&lt;br /&gt;  3  from dual&lt;br /&gt;  4  connect by level &amp;lt; 501&lt;br /&gt;  5  /&lt;br /&gt;&lt;br /&gt;500 rows created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; create index NDX_T_I_T_2_D on TABLE_IN_TBS_2_DROP (col_1) tablespace TBS_2_DROP;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; -- now connect AS SYSDBA&lt;br /&gt;SQL&amp;gt; connect / as sysdba&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; select segment_name, segment_type, bytes/1048576&lt;br /&gt;  2  from dba_segments&lt;br /&gt;  3  where tablespace_name = 'TBS_2_DROP'&lt;br /&gt;  4  /&lt;br /&gt;&lt;br /&gt;SEGMENT_NAME         SEGMENT_ BYTES/1048576&lt;br /&gt;-------------------- -------- -------------&lt;br /&gt;TABLE_IN_TBS_2_DROP  TABLE            .0625&lt;br /&gt;NDX_T_I_T_2_D        INDEX            .0625&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; alter tablespace TBS_2_DROP begin backup;&lt;br /&gt;&lt;br /&gt;Tablespace altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; drop tablespace TBS_2_DROP including contents;&lt;br /&gt;drop tablespace TBS_2_DROP including contents&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-01150: cannot prevent writes - file 14 has online backup set&lt;br /&gt;ORA-01110: data file 14: '/tmp/tbs_2_drop.dbf'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; select segment_name, segment_type, bytes/1048576&lt;br /&gt;  2  from user_segments&lt;br /&gt;  3  where tablespace_name = 'TBS_2_DROP'&lt;br /&gt;  4  /&lt;br /&gt;&lt;br /&gt;no rows selected&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; select object_name, original_name, type&lt;br /&gt;  2  from dba_recyclebin&lt;br /&gt;  3  where owner = 'HEMANT'&lt;br /&gt;  4  /&lt;br /&gt;&lt;br /&gt;no rows selected&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;Although the DROP TABLESPACE failed with an ORA-1150 error, it did execute the recursive sqls drop segments present in the Tablespace.  And these segments are not recoverable now !&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7583821559406410224?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7583821559406410224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7583821559406410224' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7583821559406410224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7583821559406410224'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/12/drop-tablespace-including-contents.html' title='DROP TABLESPACE INCLUDING CONTENTS drops segments'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7100471763483328999</id><published>2011-12-26T22:01:00.001+08:00</published><updated>2011-12-26T22:01:03.751+08:00</updated><title type='text'>(Off-Topic)   How NOT to make a chart</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://xkcd.com/688/"&gt;These&lt;/a&gt; are charts which convey information with no meaning.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7100471763483328999?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7100471763483328999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7100471763483328999' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7100471763483328999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7100471763483328999'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/12/off-topic-how-not-to-make-chart.html' title='(Off-Topic)   How NOT to make a chart'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-9124389175843272195</id><published>2011-12-21T00:27:00.001+08:00</published><updated>2011-12-21T23:34:54.421+08:00</updated><title type='text'>AIOUG Sangam '11 photographs</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Photographs of the two-day AIOUG Sangam '11 conference are now accessible from &lt;a href="http://www.aioug.org/"&gt;www.aioug.org &lt;/a&gt;&lt;br /&gt; &lt;br /&gt; .&lt;br /&gt; &lt;br /&gt; .&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;div style="clear: both; font-size: xx-small; text-align: center;"&gt;Published with Blogger-droid v2.0.2&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-9124389175843272195?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/9124389175843272195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=9124389175843272195' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/9124389175843272195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/9124389175843272195'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/12/aioug-sangam-photographs.html' title='AIOUG Sangam &amp;#39;11 photographs'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-2110563896025266684</id><published>2011-12-12T17:29:00.001+08:00</published><updated>2011-12-13T01:01:35.410+08:00</updated><title type='text'>AIOUG Sangam 11 content</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;These are the two Topics that I presented at AIOUG Sangam '11 at Bangalore on 09th and 10th December 2011 :&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;The Role of the DBA :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Article : &amp;nbsp;"&lt;a href="https://docs.google.com/viewer?a=v&amp;amp;pid=sites&amp;amp;srcid=ZGVmYXVsdGRvbWFpbnxoZW1hbnRzd2Vic2l0ZXxneDo1ZDMwMDBjM2MxMTRkMzk0"&gt;The Role of the DBA&lt;/a&gt;"&lt;br /&gt;&lt;br /&gt;Presentation : &amp;nbsp;"&lt;a href="https://docs.google.com/viewer?a=v&amp;amp;pid=sites&amp;amp;srcid=ZGVmYXVsdGRvbWFpbnxoZW1hbnRzd2Vic2l0ZXxneDoxNmY5MTRjNjVhN2I2ZDU5"&gt;The Role of the DBA&lt;/a&gt;"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Partitioning :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt; Article : &amp;nbsp;"&lt;a href="https://docs.google.com/viewer?a=v&amp;amp;pid=sites&amp;amp;srcid=ZGVmYXVsdGRvbWFpbnxoZW1hbnRzd2Vic2l0ZXxneDo0YTU0OWE2YzczMzliMjBh"&gt;Partitioning Tables and Indexing Them&lt;/a&gt;". &amp;nbsp;This contains additional examples that could not be included in the Presentation.&lt;br /&gt;&lt;br /&gt;Presentation : &amp;nbsp;"&lt;a href="https://docs.google.com/viewer?a=v&amp;amp;pid=sites&amp;amp;srcid=ZGVmYXVsdGRvbWFpbnxoZW1hbnRzd2Vic2l0ZXxneDo2YWY0ZWJkZmEyNzZlNmRl"&gt;Partitioning Tables and Indexing Them&lt;/a&gt;".&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="clear: both; font-size: xx-small; text-align: center;"&gt;Published with Blogger-droid v2.0&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-2110563896025266684?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/2110563896025266684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=2110563896025266684' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2110563896025266684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2110563896025266684'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/12/aioug-sangam-11-content.html' title='AIOUG Sangam 11 content'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4415789307647520924</id><published>2011-11-30T22:21:00.001+08:00</published><updated>2011-11-30T22:21:54.107+08:00</updated><title type='text'>Constraints and Indexes</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Here is an interesting discussion on &lt;a href="https://forums.oracle.com/forums/thread.jspa?threadID=2205686"&gt;Constraints and Indexes&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4415789307647520924?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4415789307647520924/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4415789307647520924' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4415789307647520924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4415789307647520924'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/constraints-and-indexes.html' title='Constraints and Indexes'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-2704705535603560982</id><published>2011-11-28T22:00:00.001+08:00</published><updated>2011-11-28T22:01:59.627+08:00</updated><title type='text'>Oracle PreConfigured Templates</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;A quick post to list the Oracle PreConfigured Templates :&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.oracle.com/technetwork/server-storage/vm/overview/templates-101937.html"&gt;Oracle VM Templates that can be used for Test/Development *and* Production setup on Oracle VM&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.oracle.com/technetwork/community/developer-vm/index.html"&gt;Oracle VirtualBox VMs for Developers&lt;/a&gt; -- as VirtualBox can be easily installed on desktops&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-2704705535603560982?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2704705535603560982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2704705535603560982'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/oracle-preconfigured-templates.html' title='Oracle PreConfigured Templates'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-5313655016785082752</id><published>2011-11-25T22:54:00.001+08:00</published><updated>2011-11-25T22:55:15.169+08:00</updated><title type='text'>SSDs for Oracle</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Gwen Shapira has investigated SSDs and Flash and published her findings as "&lt;a href="http://www.pythian.com/news/28797/de-confusing-ssd-for-oracle-databases/"&gt;De-Confusing SSD (for Oracle Databases)&lt;/a&gt;". &amp;nbsp; The post *and* the comments are worth a read.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-5313655016785082752?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/5313655016785082752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=5313655016785082752' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5313655016785082752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5313655016785082752'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/ssds-for-oracle.html' title='SSDs for Oracle'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7107474452303722657</id><published>2011-11-22T22:43:00.001+08:00</published><updated>2011-11-22T23:15:37.963+08:00</updated><title type='text'>ROWIDs from an Index</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Earlier today there was a question : "can i use rowid as a column in index columns ?"&lt;br /&gt;&lt;br /&gt;It's clear that you cannot index the ROWID :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; create table obj_list_tbl as select * from dba_objects;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select rowid from obj_list_tbl where object_id between 1001 and 1005;&lt;br /&gt;&lt;br /&gt;ROWID&lt;br /&gt;------------------&lt;br /&gt;AAAU1bAAEAAAEU+ABG&lt;br /&gt;AAAU1bAAEAAAEU+ABH&lt;br /&gt;AAAU1bAAEAAAEU+ABI&lt;br /&gt;AAAU1bAAEAAAEU+ABJ&lt;br /&gt;AAAU1bAAEAAAEU+ABK&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create index obj_list_tbl_rid_ndx on obj_list_tbl(rowid);&lt;br /&gt;create index obj_list_tbl_rid_ndx on obj_list_tbl(rowid)&lt;br /&gt;                                                  *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00904: : invalid identifier&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create index obj_list_tbl_oid_ndx on obj_list_tbl(object_id);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;Although we can retrieve the ROWID for each row in the table, we cannot index it as it is a pseudo-column.&lt;br /&gt;&lt;br /&gt;However, can we use an Index to retrieve *all* the ROWIDs of a table, without having to do a FullTableScan ?&lt;br /&gt;Yes &amp;nbsp;Since an Index is essentially a list of KeyValues and matching ROWIDs, we can read ROWIDs from an Index.&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; explain plan for select rowid from obj_list_tbl where object_id between 1001 and 1005;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;--------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 2458170317&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation        | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT |                      |     5 |   125 |     2   (0)| 00:00:01 |&lt;br /&gt;|*  1 |  INDEX RANGE SCAN| OBJ_LIST_TBL_OID_NDX |     5 |   125 |     2   (0)| 00:00:01 |&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;   1 - access("OBJECT_ID"&amp;gt;=1001 AND "OBJECT_ID"&amp;lt;=1005)&lt;br /&gt;&lt;br /&gt;Note&lt;br /&gt;-----&lt;br /&gt;   - dynamic sampling used for this statement (level=2)&lt;br /&gt;&lt;br /&gt;17 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;SQL&amp;gt; exec dbms_stats.gather_table_stats('HEMANT','OBJ_LIST_TBL',estimate_percent=&amp;gt;100,cascade=&amp;gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; explain plan for select rowid from obj_list_tbl where object_id between 1001 and 1011;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;--------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 2458170317&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation        | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT |                      |    11 |   187 |     2   (0)| 00:00:01 |&lt;br /&gt;|*  1 |  INDEX RANGE SCAN| OBJ_LIST_TBL_OID_NDX |    11 |   187 |     2   (0)| 00:00:01 |&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;   1 - access("OBJECT_ID"&amp;gt;=1001 AND "OBJECT_ID"&amp;lt;=1011)&lt;br /&gt;&lt;br /&gt;13 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;Thus, Oracle could do an Index Range Scan to retrieve ROWIDs.  Why would we want ROWIDs ?  Probably to identify the datafiles that contain the rows of interest :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; l&lt;br /&gt;  1  select file_name from dba_data_files&lt;br /&gt;  2  where tablespace_name = 'USERS'&lt;br /&gt;  3  and relative_fno in&lt;br /&gt;  4  (select distinct row_file_relative_no&lt;br /&gt;  5  from (select dbms_rowid.rowid_relative_fno(rowid) as row_file_relative_no&lt;br /&gt;  6        from obj_list_tbl where object_id between 1001 and 1011)&lt;br /&gt;  7* )&lt;br /&gt;SQL&amp;gt; /&lt;br /&gt;&lt;br /&gt;FILE_NAME&lt;br /&gt;----------------------------------------------------------------&lt;br /&gt;/home/oracle/app/oracle/oradata/orcl/users01.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;Can we retrieve all the ROWIDs of the table from the Index ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; explain plan for&lt;br /&gt;  2  select /*+ INDEX (O OBJ_LIST_OID_NDX) */  rowid from obj_list_tbl O;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;--------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 4249882908&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation         | Name         | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;----------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT  |              | 76967 |   901K|   307   (1)| 00:00:04 |&lt;br /&gt;|   1 |  TABLE ACCESS FULL| OBJ_LIST_TBL | 76967 |   901K|   307   (1)| 00:00:04 |&lt;br /&gt;----------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;8 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;Why did Oracle choose to do a FullTableScan ?In the absence of a WHERE clause, the requirement is for all the rows of the table.   However, an Index can be used only if it is known to have captured all the rows of the table.  If the Index is on a column that is NULLABLE (i.e. is not a NOT NULL), the Optimizer cannot be sure that it captures all the rows as NULLs are not indexed (in a regular B-Tree index).I need to confirm that all the rows are indexed.  &lt;br /&gt;&lt;pre&gt;SQL&amp;gt; alter table obj_list_tbl modify (object_id not null);&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; explain plan for&lt;br /&gt;  2  select /*+ INDEX (O OBJ_LIST_OID_NDX) */  rowid from obj_list_tbl O;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;--------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 2780527016&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation            | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;---------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT     |                      | 76967 |   901K|    48   (0)| 00:00:01 |&lt;br /&gt;|   1 |  INDEX FAST FULL SCAN| OBJ_LIST_TBL_OID_NDX | 76967 |   901K|    48   (0)| 00:00:01 |&lt;br /&gt;---------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;8 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;Now that the column has been validated to be a NOT NULL, the Optimizer can be certain that every row has been indexed by an Index on this column.  So, it can now use the Index.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7107474452303722657?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7107474452303722657/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7107474452303722657' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7107474452303722657'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7107474452303722657'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/rowids-from-index.html' title='ROWIDs from an Index'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-6206504807668299121</id><published>2011-11-16T22:29:00.001+08:00</published><updated>2011-11-16T22:30:31.190+08:00</updated><title type='text'>RESTORE, RECOVER and RESETLOGS</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Two recent forums threads on understanding database RESTORE, RECOVER and RESETLOGS :&lt;br /&gt;&lt;br /&gt;&lt;a href="https://forums.oracle.com/forums/thread.jspa?threadID=2309988&amp;amp;tstart=0"&gt;Question on Redo log file creation after Restore and Recover&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://forums.oracle.com/forums/thread.jspa?threadID=2310693&amp;amp;tstart=0"&gt;Restoring and Recovering RMAN backup in a New server&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-6206504807668299121?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/6206504807668299121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=6206504807668299121' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6206504807668299121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6206504807668299121'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/restore-recover-and-resetlogs.html' title='RESTORE, RECOVER and RESETLOGS'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-3625408756586714182</id><published>2011-11-09T23:17:00.001+08:00</published><updated>2011-11-26T23:03:27.583+08:00</updated><title type='text'>Grid and RAC Notes</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div&gt;This is a place-holder for miscellaneous notes on 11gR2 Grid and RAC.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;strong&gt;09-Nov-11 : Location of Voting disk&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;If the voting disk exists on ASM you cannot add CFS votedisks.  You must replace your ASM voting disk with the CFS votedisks.  Apparently, both location types&amp;nbsp;cannot be used concurrently ?&lt;/div&gt;&lt;pre&gt;[root@node1 crs]# crsctl query css votedisk&lt;br /&gt;##  STATE    File Universal Id                File Name Disk group&lt;br /&gt;--  -----    -----------------                --------- ---------&lt;br /&gt; 1. ONLINE   5e25b31afc8e4fcabf3af0462e71ada9 (/crs/ocr.configuration) [DATA]&lt;br /&gt;Located 1 voting disk(s).&lt;br /&gt;[root@node1 crs]#&lt;br /&gt;[root@node1 crs]# crsctl add css votedisk /data1/votedisk.1 /data2/votedisk.2&lt;br /&gt;CRS-4258: Addition and deletion of voting files are not allowed because the voting files are on ASM&lt;br /&gt;[root@node1 crs]# crsctl replace votedisk /data1/votedisk.1 /data2/votedisk.2&lt;br /&gt;Now formatting voting disk: /data1/votedisk.1.&lt;br /&gt;Now formatting voting disk: /data2/votedisk.2.&lt;br /&gt;CRS-4256: Updating the profile&lt;br /&gt;Successful addition of voting disk 0ba633a673684fc0bf95cfbf188c399b.&lt;br /&gt;Successful addition of voting disk 5784bae373ba4fcfbfb5c89b7136a7ea.&lt;br /&gt;Successful deletion of voting disk 5e25b31afc8e4fcabf3af0462e71ada9.&lt;br /&gt;CRS-4256: Updating the profile&lt;br /&gt;CRS-4266: Voting file(s) successfully replaced&lt;br /&gt;[root@node1 crs]# crsctl query css votedisk&lt;br /&gt;##  STATE    File Universal Id                File Name Disk group&lt;br /&gt;--  -----    -----------------                --------- ---------&lt;br /&gt; 1. ONLINE   0ba633a673684fc0bf95cfbf188c399b (/data1/votedisk.1) []&lt;br /&gt; 2. ONLINE   5784bae373ba4fcfbfb5c89b7136a7ea (/data2/votedisk.2) []&lt;br /&gt;Located 2 voting disk(s).&lt;br /&gt;[root@node1 crs]# ls -l /data*/*otedi*&lt;br /&gt;-rw-r----- 1 grid oinstall 21004800 Nov  9 22:52 /data1/votedisk.1&lt;br /&gt;-rw-r----- 1 grid oinstall 21004800 Nov  9 22:52 /data2/votedisk.2&lt;br /&gt;[root@node1 crs]#&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;So, I have now "moved" the voting disk from ASM (+DATA) to CFS (two separate files on two separate mount-points).  (Note  : /crs/ocr.configuration is actually an ASM disk).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;09-Nov-11 :&amp;nbsp; OCR Backups are going to node1 only ?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I have a two-node RAC.&amp;nbsp; "Automatic"&amp;nbsp; *and* Manual OCR Backups are being created on node1.&amp;nbsp; I expect the backups to be spread out to different nodes.&lt;br /&gt;&lt;pre&gt;[root@node2 ~]# uname -a&lt;br /&gt;Linux node2.mydomain.com 2.6.18-238.el5 #1 SMP Tue Jan 4 15:24:05 EST 2011 i686 i686 i386 GNU/Linux&lt;br /&gt;[root@node2 ~]# ocrconfig -showbackup&lt;br /&gt;&lt;br /&gt;node1     2011/10/22 03:09:03     /u01/app/grid/11.2.0/cdata/rac/backup00.ocr&lt;br /&gt;&lt;br /&gt;node1     2011/10/21 23:06:39     /u01/app/grid/11.2.0/cdata/rac/backup01.ocr&lt;br /&gt;&lt;br /&gt;node1     2011/10/21 23:06:39     /u01/app/grid/11.2.0/cdata/rac/day.ocr&lt;br /&gt;&lt;br /&gt;node1     2011/10/21 23:06:39     /u01/app/grid/11.2.0/cdata/rac/week.ocr&lt;br /&gt;&lt;br /&gt;node1     2011/11/09 23:09:16     /u01/app/grid/11.2.0/cdata/rac/backup_20111109_230916.ocr&lt;br /&gt;&lt;br /&gt;node1     2011/11/09 22:47:25     /u01/app/grid/11.2.0/cdata/rac/backup_20111109_224725.ocr&lt;br /&gt;&lt;br /&gt;node1     2011/11/09 22:29:41     /u01/app/grid/11.2.0/cdata/rac/backup_20111109_222941.ocr&lt;br /&gt;[root@node2 ~]# ocrconfig -manualbackup&lt;br /&gt;&lt;br /&gt;node1     2011/11/09 23:09:40     /u01/app/grid/11.2.0/cdata/rac/backup_20111109_230940.ocr&lt;br /&gt;&lt;br /&gt;node1     2011/11/09 23:09:16     /u01/app/grid/11.2.0/cdata/rac/backup_20111109_230916.ocr&lt;br /&gt;&lt;br /&gt;node1     2011/11/09 22:47:25     /u01/app/grid/11.2.0/cdata/rac/backup_20111109_224725.ocr&lt;br /&gt;&lt;br /&gt;node1     2011/11/09 22:29:41     /u01/app/grid/11.2.0/cdata/rac/backup_20111109_222941.ocr&lt;br /&gt;[root@node2 ~]# &lt;br /&gt;&lt;/pre&gt;Commands fired from node2 show that all backups, even manual backups are on node1.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;09-Nov-11 :&amp;nbsp; Shutdown of services from a node&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;crsctl can be used to shutdown all services.&amp;nbsp; Here I shutdown the local node :&lt;br /&gt;&lt;pre&gt;[root@node2 log]# crsctl stop  cluster&lt;br /&gt;CRS-2673: Attempting to stop 'ora.crsd' on 'node2'&lt;br /&gt;CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'node2'&lt;br /&gt;CRS-2673: Attempting to stop 'ora.LISTENER_SCAN1.lsnr' on 'node2'&lt;br /&gt;CRS-2673: Attempting to stop 'ora.DATA.dg' on 'node2'&lt;br /&gt;CRS-2673: Attempting to stop 'ora.registry.acfs' on 'node2'&lt;br /&gt;CRS-2673: Attempting to stop 'ora.DATA1.dg' on 'node2'&lt;br /&gt;CRS-2673: Attempting to stop 'ora.DATA2.dg' on 'node2'&lt;br /&gt;CRS-2673: Attempting to stop 'ora.FRA.dg' on 'node2'&lt;br /&gt;CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.LISTENER_SCAN1.lsnr' on 'node2' succeeded&lt;br /&gt;CRS-2673: Attempting to stop 'ora.scan1.vip' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.scan1.vip' on 'node2' succeeded&lt;br /&gt;CRS-2672: Attempting to start 'ora.scan1.vip' on 'node1'&lt;br /&gt;CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'node2' succeeded&lt;br /&gt;CRS-2673: Attempting to stop 'ora.node2.vip' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.node2.vip' on 'node2' succeeded&lt;br /&gt;CRS-2672: Attempting to start 'ora.node2.vip' on 'node1'&lt;br /&gt;CRS-2677: Stop of 'ora.registry.acfs' on 'node2' succeeded&lt;br /&gt;CRS-2676: Start of 'ora.node2.vip' on 'node1' succeeded&lt;br /&gt;CRS-2676: Start of 'ora.scan1.vip' on 'node1' succeeded&lt;br /&gt;CRS-2672: Attempting to start 'ora.LISTENER_SCAN1.lsnr' on 'node1'&lt;br /&gt;CRS-2677: Stop of 'ora.FRA.dg' on 'node2' succeeded&lt;br /&gt;CRS-2677: Stop of 'ora.DATA1.dg' on 'node2' succeeded&lt;br /&gt;CRS-2677: Stop of 'ora.DATA2.dg' on 'node2' succeeded&lt;br /&gt;CRS-2676: Start of 'ora.LISTENER_SCAN1.lsnr' on 'node1' succeeded&lt;br /&gt;CRS-2677: Stop of 'ora.DATA.dg' on 'node2' succeeded&lt;br /&gt;CRS-2673: Attempting to stop 'ora.asm' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.asm' on 'node2' succeeded&lt;br /&gt;CRS-2673: Attempting to stop 'ora.ons' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.ons' on 'node2' succeeded&lt;br /&gt;CRS-2673: Attempting to stop 'ora.net1.network' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.net1.network' on 'node2' succeeded&lt;br /&gt;CRS-2792: Shutdown of Cluster Ready Services-managed resources on 'node2' has completed&lt;br /&gt;CRS-2677: Stop of 'ora.crsd' on 'node2' succeeded&lt;br /&gt;CRS-2673: Attempting to stop 'ora.ctssd' on 'node2'&lt;br /&gt;CRS-2673: Attempting to stop 'ora.evmd' on 'node2'&lt;br /&gt;CRS-2673: Attempting to stop 'ora.asm' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.evmd' on 'node2' succeeded&lt;br /&gt;CRS-2677: Stop of 'ora.asm' on 'node2' succeeded&lt;br /&gt;CRS-2673: Attempting to stop 'ora.cluster_interconnect.haip' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.cluster_interconnect.haip' on 'node2' succeeded&lt;br /&gt;CRS-2677: Stop of 'ora.ctssd' on 'node2' succeeded&lt;br /&gt;CRS-2673: Attempting to stop 'ora.cssd' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.cssd' on 'node2' succeeded&lt;br /&gt;CRS-2673: Attempting to stop 'ora.diskmon' on 'node2'&lt;br /&gt;CRS-2677: Stop of 'ora.diskmon' on 'node2' succeeded&lt;br /&gt;[root@node2 log]# &lt;br /&gt;[root@node2 log]# ps -fugrid&lt;br /&gt;UID        PID  PPID  C STIME TTY          TIME CMD&lt;br /&gt;grid      3169     1  0 22:24 ?        00:00:32 /u01/app/grid/11.2.0/bin/oraagent.bin&lt;br /&gt;grid      3183     1  0 22:24 ?        00:00:00 /u01/app/grid/11.2.0/bin/mdnsd.bin&lt;br /&gt;grid      3194     1  0 22:24 ?        00:00:06 /u01/app/grid/11.2.0/bin/gpnpd.bin&lt;br /&gt;grid      3207     1  2 22:24 ?        00:01:46 /u01/app/grid/11.2.0/bin/gipcd.bin&lt;br /&gt;[root@node2 log]# &lt;br /&gt;&lt;/pre&gt;Only the basic services are running now.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;&lt;b&gt;26-Nov-11 : &amp;nbsp;IP Addresses&lt;/b&gt;&lt;br /&gt;On node 1 :&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select instance_number, instance_name from v$instance;&lt;br /&gt;&lt;br /&gt;INSTANCE_NUMBER INSTANCE_NAME&lt;br /&gt;--------------- ----------------&lt;br /&gt;              1 RACDB_1&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; show parameter local_listener&lt;br /&gt;&lt;br /&gt;NAME_COL_PLUS_SHOW_PARAM&lt;br /&gt;------------------------------------------------------------------------------&lt;br /&gt;TYPE&lt;br /&gt;-----------&lt;br /&gt;VALUE_COL_PLUS_SHOW_PARAM&lt;br /&gt;------------------------------------------------------------------------------&lt;br /&gt;local_listener&lt;br /&gt;string&lt;br /&gt;(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.149)(PORT=1&lt;br /&gt;521))))&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;One node 2 :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select instance_number, instance_name from v$instance;&lt;br /&gt;&lt;br /&gt;INSTANCE_NUMBER INSTANCE_NAME&lt;br /&gt;--------------- ----------------&lt;br /&gt;              2 RACDB_2&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; show parameter local_listener&lt;br /&gt;&lt;br /&gt;NAME_COL_PLUS_SHOW_PARAM&lt;br /&gt;------------------------------------------------------------------------------&lt;br /&gt;TYPE&lt;br /&gt;-----------&lt;br /&gt;VALUE_COL_PLUS_SHOW_PARAM&lt;br /&gt;------------------------------------------------------------------------------&lt;br /&gt;local_listener&lt;br /&gt;string&lt;br /&gt;(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.144)(PORT=1&lt;br /&gt;521))))&lt;br /&gt;SQL&amp;gt; &lt;br /&gt;&lt;/pre&gt;The /var/messages/log file on node1 has :&lt;br /&gt;&lt;pre&gt;Nov 26 22:12:22 node1 avahi-daemon[2572]: Registering new address record for 192.168.56.127 on eth0.&lt;br /&gt;Nov 26 22:12:27 node1 avahi-daemon[2572]: Registering new address record for 192.168.56.148 on eth0.&lt;br /&gt;Nov 26 22:12:28 node1 avahi-daemon[2572]: Registering new address record for 192.168.56.146 on eth0.&lt;br /&gt;Nov 26 22:12:28 node1 avahi-daemon[2572]: Registering new address record for 192.168.56.147 on eth0.&lt;br /&gt;Nov 26 22:12:28 node1 avahi-daemon[2572]: Registering new address record for 192.168.56.144 on eth0.&lt;br /&gt;Nov 26 22:12:28 node1 avahi-daemon[2572]: Registering new address record for 192.168.56.149 on eth0.&lt;br /&gt;Nov 26 22:18:46 node1 avahi-daemon[2572]: Withdrawing address record for 192.168.56.144 on eth0.&lt;br /&gt;Nov 26 22:18:48 node1 avahi-daemon[2572]: Withdrawing address record for 192.168.56.148 on eth0.&lt;br /&gt;&lt;/pre&gt;while node2 has :&lt;br /&gt;&lt;pre&gt;Nov 26 22:18:48 node2 avahi-daemon[2573]: Registering new address record for 192.168.56.144 on eth0.&lt;br /&gt;Nov 26 22:18:50 node2 avahi-daemon[2573]: Registering new address record for 192.168.56.148 on eth0.&lt;br /&gt;&lt;/pre&gt;These are the assigned IP addressees. 1448 and 148 switched from node1 to node2 when node2 came up.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-3625408756586714182?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/3625408756586714182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=3625408756586714182' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3625408756586714182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3625408756586714182'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/grid-and-rac-notes.html' title='Grid and RAC Notes'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7807535556330280869</id><published>2011-11-07T15:03:00.003+08:00</published><updated>2011-11-07T15:07:43.136+08:00</updated><title type='text'>Oracle's Best-Of-Breed Strategy</title><content type='html'>Mark Hurd talks to IDG Enterprise about &lt;a href="http://www.computerworld.com/s/article/9221459/Oracle_s_best_of_breed_strategy_as_described_by_president_Mark_Hurd"&gt;Oracle's Best-Of-Breed Strategy&lt;/a&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7807535556330280869?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7807535556330280869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7807535556330280869' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7807535556330280869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7807535556330280869'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/oracles-best-of-breed-strategy.html' title='Oracle&apos;s Best-Of-Breed Strategy'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4890314903670381218</id><published>2011-11-05T11:40:00.002+08:00</published><updated>2011-11-05T12:08:13.744+08:00</updated><title type='text'>Tablespace Recovery in a NOARCHIVELOG database</title><content type='html'>Following up on my previous blog, I show a Tablespace Restore and Recovery for a NOARCHIVELOG mode database.&lt;div&gt;&lt;b&gt;This is possible only if all the redo is still available in the online redo logs. !&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;Do not attempt this if the online redo logs have suffered enough switches that the log that was current during backup and the  subsequent transaction(s) has been overwritten.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First, I create a new tablespace :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; connect / as sysdba&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; archive log list&lt;br /&gt;Database log mode              No Archive Mode&lt;br /&gt;Automatic archival             Disabled&lt;br /&gt;Archive destination            USE_DB_RECOVERY_FILE_DEST&lt;br /&gt;Oldest online log sequence     295&lt;br /&gt;Current log sequence           297&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; create tablespace TBS_RECOVERY ;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select file_name from dba_data_files where tablespace_name = 'TBS_RECOVERY';&lt;br /&gt;&lt;br /&gt;FILE_NAME&lt;br /&gt;--------------------------------------------------------------------------------------------------------------&lt;br /&gt;/home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9crk23_.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- startup in MOUNT mode for an RMAN Backup&lt;br /&gt;SQL&amp;gt; shutdown immediate&lt;br /&gt;Database closed.&lt;br /&gt;Database dismounted.&lt;br /&gt;ORACLE instance shut down.&lt;br /&gt;SQL&amp;gt; startup mount&lt;br /&gt;ORACLE instance started.&lt;br /&gt;&lt;br /&gt;Total System Global Area  535662592 bytes&lt;br /&gt;Fixed Size                  1337720 bytes&lt;br /&gt;Variable Size             213911176 bytes&lt;br /&gt;Database Buffers          314572800 bytes&lt;br /&gt;Redo Buffers                5840896 bytes&lt;br /&gt;Database mounted.&lt;br /&gt;SQL&amp;gt; archive log list&lt;br /&gt;Database log mode              No Archive Mode&lt;br /&gt;Automatic archival             Disabled&lt;br /&gt;Archive destination            USE_DB_RECOVERY_FILE_DEST&lt;br /&gt;Oldest online log sequence     295&lt;br /&gt;Current log sequence           297&lt;br /&gt;SQL&amp;gt; pause Run an RMAN Backup of the tablespace&lt;br /&gt;Run an RMAN Backup of the tablespace&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then I run an RMAN backup :&lt;br /&gt;&lt;pre&gt;RMAN&amp;gt; backup tablespace TBS_RECOVERY;&lt;br /&gt;&lt;br /&gt;Starting backup at 05-NOV-11&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=20 device type=DISK&lt;br /&gt;allocated channel: ORA_DISK_2&lt;br /&gt;channel ORA_DISK_2: SID=21 device type=DISK&lt;br /&gt;channel ORA_DISK_1: starting full datafile backup set&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) in backup set&lt;br /&gt;input datafile file number=00018 name=/home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9crk23_.dbf&lt;br /&gt;channel ORA_DISK_1: starting piece 1 at 05-NOV-11&lt;br /&gt;channel ORA_DISK_1: finished piece 1 at 05-NOV-11&lt;br /&gt;piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2011_11_05/o1_mf_nnndf_TAG20111105T113924_7c9czg54_.bkp tag=TAG20111105T113924 comment=NONE&lt;br /&gt;channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02&lt;br /&gt;Finished backup at 05-NOV-11&lt;br /&gt;&lt;br /&gt;Starting Control File and SPFILE Autobackup at 05-NOV-11&lt;br /&gt;piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2011_11_05/o1_mf_s_766409773_7c9czltz_.bkp comment=NONE&lt;br /&gt;Finished Control File and SPFILE Autobackup at 05-NOV-11&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, I proceed to put some data into the tablespace :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; alter database open;&lt;br /&gt;&lt;br /&gt;Database altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; -- get current SCN&lt;br /&gt;SQL&amp;gt; select current_scn from v$database;&lt;br /&gt;&lt;br /&gt;CURRENT_SCN&lt;br /&gt;-----------&lt;br /&gt;5482811&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select to_char(sysdate,'DD-MON HH24:MI') from dual;&lt;br /&gt;&lt;br /&gt;TO_CHAR(SYSDATE,'DD-M&lt;br /&gt;---------------------&lt;br /&gt;05-NOV 11:41&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- run regular insert&lt;br /&gt;SQL&amp;gt; create table INSERT_TBL tablespace TBS_RECOVERY&lt;br /&gt;2  as select * from dba_objects where 1=2;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into INSERT_TBL select * from dba_objects;&lt;br /&gt;&lt;br /&gt;76684 rows created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- run CTAS&lt;br /&gt;SQL&amp;gt; create table CTAS_TBL tablespace TBS_RECOVERY as select * from dba_objects;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select segment_name, segment_type, bytes from user_segments&lt;br /&gt;2  where tablespace_name = 'TBS_RECOVERY';&lt;br /&gt;&lt;br /&gt;SEGMENT_NAME                   SEGMENT_TYPE            BYTES&lt;br /&gt;------------------------------ ------------------ ----------&lt;br /&gt;INSERT_TBL                     TABLE                 9437184&lt;br /&gt;CTAS_TBL                       TABLE                 9437184&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- check unrecoverable stamps on the datafile&lt;br /&gt;SQL&amp;gt; select unrecoverable_change#, to_char(unrecoverable_time,'DD-MON HH24:MI')&lt;br /&gt;2  from v$datafile, dba_data_files&lt;br /&gt;3  where file#=file_id&lt;br /&gt;4  and tablespace_name = 'TBS_RECOVERY'&lt;br /&gt;5  /&lt;br /&gt;&lt;br /&gt;UNRECOVERABLE_CHANGE# TO_CHAR(UNRECOVERABLE&lt;br /&gt;--------------------- ---------------------&lt;br /&gt;                0&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- get current SCN&lt;br /&gt;SQL&amp;gt; select current_scn from v$database;&lt;br /&gt;&lt;br /&gt;CURRENT_SCN&lt;br /&gt;-----------&lt;br /&gt;5482969&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select to_char(sysdate,'DD-MON HH24:MI') from dual;&lt;br /&gt;&lt;br /&gt;TO_CHAR(SYSDATE,'DD-M&lt;br /&gt;---------------------&lt;br /&gt;05-NOV 11:41&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; connect / as sysdba&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; -- set tablespace offline&lt;br /&gt;SQL&amp;gt; alter tablespace TBS_RECOVERY offline;&lt;br /&gt;&lt;br /&gt;Tablespace altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; pause Remove datafile and restore and recover datafile&lt;br /&gt;Remove datafile and restore and recover datafile&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I remove the datafile :&lt;br /&gt;&lt;pre&gt;[root@localhost ~]# ls -l /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9crk23_.dbf&lt;br /&gt;-rw-rw---- 1 oracle oracle 104865792 Nov  5 11:41 /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9crk23_.dbf&lt;br /&gt;[root@localhost ~]# rm /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9crk23_.dbf&lt;br /&gt;rm: remove regular file `/home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9crk23_.dbf'? yes&lt;br /&gt;[root@localhost ~]# ls -l /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9crk23_.dbf&lt;br /&gt;ls: /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9crk23_.dbf: No such file or directory&lt;br /&gt;[root@localhost ~]#&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I then RESTORE and RECOVER the tablespace :&lt;br /&gt;&lt;pre&gt;RMAN&amp;gt; restore tablespace TBS_RECOVERY;&lt;br /&gt;&lt;br /&gt;Starting restore at 05-NOV-11&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=21 device type=DISK&lt;br /&gt;allocated channel: ORA_DISK_2&lt;br /&gt;channel ORA_DISK_2: SID=20 device type=DISK&lt;br /&gt;&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00018 to /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9crk23_.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2011_11_05/o1_mf_nnndf_TAG20111105T113924_7c9czg54_.bkp&lt;br /&gt;channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2011_11_05/o1_mf_nnndf_TAG20111105T113924_7c9czg54_.bkp tag=TAG20111105T113924&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:00:07&lt;br /&gt;Finished restore at 05-NOV-11&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; recover tablespace TBS_RECOVERY;&lt;br /&gt;&lt;br /&gt;Starting recover at 05-NOV-11&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;using channel ORA_DISK_2&lt;br /&gt;&lt;br /&gt;starting media recovery&lt;br /&gt;media recovery complete, elapsed time: 00:00:04&lt;br /&gt;&lt;br /&gt;Finished recover at 05-NOV-11&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; sql 'alter tablespace TBS_RECOVERY online';&lt;br /&gt;&lt;br /&gt;sql statement: alter tablespace TBS_RECOVERY online&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I now verify the data in the two tables :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- get current SCN&lt;br /&gt;SQL&amp;gt; select current_scn from v$database;&lt;br /&gt;&lt;br /&gt;CURRENT_SCN&lt;br /&gt;-----------&lt;br /&gt; 5483260&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select to_char(sysdate,'DD-MON HH24:MI') from dual;&lt;br /&gt;&lt;br /&gt;TO_CHAR(SYSDATE,'DD-M&lt;br /&gt;---------------------&lt;br /&gt;05-NOV 11:47&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; -- query the table&lt;br /&gt;SQL&amp;gt; select count(*) from CTAS_TBL;&lt;br /&gt;select count(*) from CTAS_TBL&lt;br /&gt;                  *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-01578: ORACLE data block corrupted (file # 18, block # 1283)&lt;br /&gt;ORA-01110: data file 18: '/home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9dc5mw_.dbf'&lt;br /&gt;ORA-26040: Data block was loaded using the NOLOGGING option&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select count(*) from INSERT_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(*)&lt;br /&gt;----------&lt;br /&gt;  76684&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;                           &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The table that was created as a CTAS operation is not readable as the rows were inserted as a NOLOGGING operation.  (See my previous blog post : "&lt;a href="http://hemantoracledba.blogspot.com/2011/11/ctas-in-noarchivelog-database-is.html"&gt;CTAS in a NOARCHIVELOG database is a NOLOGGING operation&lt;/a&gt;").&lt;div&gt;However, the table that has data inserted by regular DML, using a normal INSERT has been recovered !&lt;/div&gt;&lt;div&gt;The RECOVER was able to read from the Online Redo Logs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This case also shows how I did not have to do a Full Database Backup or a Full Database Restore+Recover.  The single Tablespace was recovered to a consistent point in time with the rest of the database as evidenced below :&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select current_scn from v$database;&lt;br /&gt;&lt;br /&gt;CURRENT_SCN&lt;br /&gt;-----------&lt;br /&gt;  5483376&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select to_char(sysdate,'DD-MON HH24:MI') from dual;&lt;br /&gt;&lt;br /&gt;TO_CHAR(SYSDATE,'DD-M&lt;br /&gt;---------------------&lt;br /&gt;05-NOV 11:51&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter system checkpoint;&lt;br /&gt;&lt;br /&gt;System altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select file#, last_change#, checkpoint_change#, to_char(checkpoint_time,'DD-MON HH24:MI')&lt;br /&gt;2  from v$datafile order by 1;&lt;br /&gt;&lt;br /&gt;   FILE# LAST_CHANGE# CHECKPOINT_CHANGE# TO_CHAR(CHECKPOINT_TI&lt;br /&gt;---------- ------------ ------------------ ---------------------&lt;br /&gt;       1                         5483383 05-NOV 11:51&lt;br /&gt;       2                         5483383 05-NOV 11:51&lt;br /&gt;       3                         5483383 05-NOV 11:51&lt;br /&gt;       4                         5483383 05-NOV 11:51&lt;br /&gt;       5                         5483383 05-NOV 11:51&lt;br /&gt;       6                         5483383 05-NOV 11:51&lt;br /&gt;       7                         5483383 05-NOV 11:51&lt;br /&gt;       8                         5483383 05-NOV 11:51&lt;br /&gt;       9                         5483383 05-NOV 11:51&lt;br /&gt;      10                         5483383 05-NOV 11:51&lt;br /&gt;      11                         5483383 05-NOV 11:51&lt;br /&gt;      12                         5483383 05-NOV 11:51&lt;br /&gt;      13                         5483383 05-NOV 11:51&lt;br /&gt;      14                         5483383 05-NOV 11:51&lt;br /&gt;      15                         5483383 05-NOV 11:51&lt;br /&gt;      16                         5483383 05-NOV 11:51&lt;br /&gt;      17                         5483383 05-NOV 11:51&lt;br /&gt;      18                         5483383 05-NOV 11:51&lt;br /&gt;&lt;br /&gt;18 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;These are the Log Sequence Numbers (selected lines from the alert.log):&lt;br /&gt;&lt;pre&gt;Sat Nov 05 11:22:02 2011&lt;br /&gt;ALTER DATABASE OPEN&lt;br /&gt;Thread 1 opened at log sequence 297&lt;br /&gt;Current log# 3 seq# 297 mem# 0: /home/oracle/app/oracle/oradata/orcl/redo03.log&lt;br /&gt;Successful open of redo thread 1&lt;br /&gt;...&lt;br /&gt;Sat Nov 05 11:22:14 2011&lt;br /&gt;QMNC started with pid=20, OS id=2378&lt;br /&gt;Completed: ALTER DATABASE OPEN&lt;br /&gt;...&lt;br /&gt;Sat Nov 05 11:35:45 2011&lt;br /&gt;create tablespace TBS_RECOVERY&lt;br /&gt;Sat Nov 05 11:35:55 2011&lt;br /&gt;Completed: create tablespace TBS_RECOVERY&lt;br /&gt;...&lt;br /&gt;Sat Nov 05 11:37:12 2011&lt;br /&gt;ALTER DATABASE   MOUNT&lt;br /&gt;Successful mount of redo thread 1, with mount id 1294202344&lt;br /&gt;Database mounted in Exclusive Mode&lt;br /&gt;Lost write protection disabled&lt;br /&gt;Completed: ALTER DATABASE   MOUNT&lt;br /&gt;...&lt;br /&gt;Sat Nov 05 11:41:13 2011&lt;br /&gt;alter database open&lt;br /&gt;Sat Nov 05 11:41:13 2011&lt;br /&gt;Thread 1 opened at log sequence 297&lt;br /&gt;Current log# 3 seq# 297 mem# 0: /home/oracle/app/oracle/oradata/orcl/redo03.log&lt;br /&gt;...&lt;br /&gt;Sat Nov 05 11:41:59 2011&lt;br /&gt;alter tablespace TBS_RECOVERY offline&lt;br /&gt;Completed: alter tablespace TBS_RECOVERY offline&lt;br /&gt;...&lt;br /&gt;Sat Nov 05 11:45:46 2011&lt;br /&gt;Full restore complete of datafile 18 /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_tbs_reco_7c9dc5mw_.dbf.  Elapsed time: 0:00:05&lt;br /&gt;checkpoint is 5482691&lt;br /&gt;Sat Nov 05 11:46:04 2011&lt;br /&gt;alter database recover datafile list clear&lt;br /&gt;Completed: alter database recover datafile list clear&lt;br /&gt;alter database recover if needed&lt;br /&gt;tablespace TBS_RECOVERY&lt;br /&gt;Media Recovery Start&lt;br /&gt;Serial Media Recovery started&lt;br /&gt;Recovery of Online Redo Log: Thread 1 Group 3 Seq 297 Reading mem 0&lt;br /&gt;Mem# 0: /home/oracle/app/oracle/oradata/orcl/redo03.log&lt;br /&gt;Media Recovery Complete (orcl)&lt;br /&gt;Completed: alter database recover if needed&lt;br /&gt;tablespace TBS_RECOVERY&lt;br /&gt;Sat Nov 05 11:46:23 2011&lt;br /&gt;alter tablespace TBS_RECOVERY online&lt;br /&gt;Completed: alter tablespace TBS_RECOVERY online&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Therefore it is possible to recover a Tablespace in a NOARCHIVELOG database in a very limited frame -- enough redo being available in the Online Redo Logs.&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4890314903670381218?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4890314903670381218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4890314903670381218' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4890314903670381218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4890314903670381218'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/tablespace-recovery-in-noarchivelog.html' title='Tablespace Recovery in a NOARCHIVELOG database'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4092315801217533171</id><published>2011-11-05T00:39:00.002+08:00</published><updated>2011-11-05T00:54:30.144+08:00</updated><title type='text'>CTAS in a NOARCHIVELOG database is a NOLOGGING operation</title><content type='html'>Normally, a CTAS (CREATE TABLE ... AS SELECT ....)  operation generates redo and logging.  However, if the database is in NOARCHIVELOG mode, Oracle silently converts it to a NOLOGGING operation.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This also means that a CTAS in a Test database (that is NOARCHIVELOG mode) will  run faster than a CTAS in a Production database (that is ARCHIVELOG mode) ,  allowing for differences in server and I/O performance.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is a demonstration :&lt;/div&gt;&lt;div&gt;I first create a Tablespace and run a Backup, with the database in NOARCHIVELOG mode :&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; archive log list&lt;br /&gt;Database log mode              No Archive Mode&lt;br /&gt;Automatic archival             Disabled&lt;br /&gt;Archive destination            USE_DB_RECOVERY_FILE_DEST&lt;br /&gt;Oldest online log sequence     295&lt;br /&gt;Current log sequence           297&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; create tablespace CTAS_NOARCH ;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select file_name from dba_data_files where tablespace_name = 'CTAS_NOARCH';&lt;br /&gt;&lt;br /&gt;FILE_NAME&lt;br /&gt;--------------------------------------------------------------------------------------------------------------&lt;br /&gt;/home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_ctas_noa_7c84n1w9_.dbf&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- startup in MOUNT mode for an RMAN Backup&lt;br /&gt;SQL&amp;gt; shutdown immediate&lt;br /&gt;Database closed.&lt;br /&gt;Database dismounted.&lt;br /&gt;ORACLE instance shut down.&lt;br /&gt;SQL&amp;gt; startup mount&lt;br /&gt;ORACLE instance started.&lt;br /&gt;&lt;br /&gt;Total System Global Area  535662592 bytes&lt;br /&gt;Fixed Size                  1337720 bytes&lt;br /&gt;Variable Size             213911176 bytes&lt;br /&gt;Database Buffers          314572800 bytes&lt;br /&gt;Redo Buffers                5840896 bytes&lt;br /&gt;Database mounted.&lt;br /&gt;SQL&amp;gt; archive log list&lt;br /&gt;Database log mode              No Archive Mode&lt;br /&gt;Automatic archival             Disabled&lt;br /&gt;Archive destination            USE_DB_RECOVERY_FILE_DEST&lt;br /&gt;Oldest online log sequence     295&lt;br /&gt;Current log sequence           297&lt;br /&gt;SQL&amp;gt; pause Run an RMAN Backup of the tablespace&lt;br /&gt;Run an RMAN Backup of the tablespace&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The RMAN backup is executed :&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;RMAN&amp;gt; backup tablespace CTAS_NOARCH;&lt;br /&gt;&lt;br /&gt;Starting backup at 05-NOV-11&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=20 device type=DISK&lt;br /&gt;allocated channel: ORA_DISK_2&lt;br /&gt;channel ORA_DISK_2: SID=21 device type=DISK&lt;br /&gt;channel ORA_DISK_1: starting full datafile backup set&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) in backup set&lt;br /&gt;input datafile file number=00017 name=/home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_ctas_noa_7c84n1w9_.dbf&lt;br /&gt;channel ORA_DISK_1: starting piece 1 at 05-NOV-11&lt;br /&gt;channel ORA_DISK_1: finished piece 1 at 05-NOV-11&lt;br /&gt;piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2011_11_05/o1_mf_nnndf_TAG20111105T003023_7c84s28w_.bkp tag=TAG20111105T003023 comment=NONE&lt;br /&gt;channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01&lt;br /&gt;Finished backup at 05-NOV-11&lt;br /&gt;&lt;br /&gt;Starting Control File and SPFILE Autobackup at 05-NOV-11&lt;br /&gt;piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2011_11_05/o1_mf_s_766369695_7c84s6ks_.bkp comment=NONE&lt;br /&gt;Finished Control File and SPFILE Autobackup at 05-NOV-11&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I then run a CTAS in the Tablespace :&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; alter database open;&lt;br /&gt;&lt;br /&gt;Database altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; -- get current SCN&lt;br /&gt;SQL&amp;gt; select current_scn from v$database;&lt;br /&gt;&lt;br /&gt;CURRENT_SCN&lt;br /&gt;-----------&lt;br /&gt;  5479486&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select to_char(sysdate,'DD-MON HH24:MI') from dual;&lt;br /&gt;&lt;br /&gt;TO_CHAR(SYSDATE,'DD-M&lt;br /&gt;---------------------&lt;br /&gt;05-NOV 00:31&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- run CTAS&lt;br /&gt;SQL&amp;gt; create table CTAS_NOARCH_TBL tablespace CTAS_NOARCH as select * from dba_objects;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- check unrecoverable stamps on the datafile&lt;br /&gt;SQL&amp;gt; select unrecoverable_change#, to_char(unrecoverable_time,'DD-MON HH24:MI')&lt;br /&gt;2  from v$datafile, dba_data_files&lt;br /&gt;3  where file#=file_id&lt;br /&gt;4  and tablespace_name = 'CTAS_NOARCH'&lt;br /&gt;5  /&lt;br /&gt;&lt;br /&gt;UNRECOVERABLE_CHANGE# TO_CHAR(UNRECOVERABLE&lt;br /&gt;--------------------- ---------------------&lt;br /&gt;                  0&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; connect / as sysdba&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; -- set tablespace offline&lt;br /&gt;SQL&amp;gt; alter tablespace CTAS_NOARCH offline;&lt;br /&gt;&lt;br /&gt;Tablespace altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; pause Remove datafile and restore and recover datafile&lt;br /&gt;Remove datafile and restore and recover datafile&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I remove the datafile and RESTORE and RECOVER the tablespace :&lt;br /&gt;&lt;pre&gt;[root@localhost ~]# rm /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_ctas_noa_7c84n1w9_.dbf&lt;br /&gt;rm: remove regular file `/home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_ctas_noa_7c84n1w9_.dbf'? yes&lt;br /&gt;[root@localhost ~]#&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; restore tablespace CTAS_NOARCH;&lt;br /&gt;&lt;br /&gt;Starting restore at 05-NOV-11&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=33 device type=DISK&lt;br /&gt;allocated channel: ORA_DISK_2&lt;br /&gt;channel ORA_DISK_2: SID=20 device type=DISK&lt;br /&gt;&lt;br /&gt;channel ORA_DISK_1: starting datafile backup set restore&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) to restore from backup set&lt;br /&gt;channel ORA_DISK_1: restoring datafile 00017 to /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_ctas_noa_7c84n1w9_.dbf&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2011_11_05/o1_mf_nnndf_TAG20111105T003023_7c84s28w_.bkp&lt;br /&gt;channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2011_11_05/o1_mf_nnndf_TAG20111105T003023_7c84s28w_.bkp tag=TAG20111105T003023&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:00:16&lt;br /&gt;Finished restore at 05-NOV-11&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; recover tablespace CTAS_NOARCH;&lt;br /&gt;&lt;br /&gt;Starting recover at 05-NOV-11&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;using channel ORA_DISK_2&lt;br /&gt;&lt;br /&gt;starting media recovery&lt;br /&gt;media recovery complete, elapsed time: 00:00:03&lt;br /&gt;&lt;br /&gt;Finished recover at 05-NOV-11&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; sql 'alter tablespace CTAS_NOARCH online';&lt;br /&gt;&lt;br /&gt;sql statement: alter tablespace CTAS_NOARCH online&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;These are the alert.log messages :&lt;br /&gt;&lt;pre&gt;Sat Nov 05 00:31:45 2011&lt;br /&gt;alter tablespace CTAS_NOARCH offline&lt;br /&gt;Completed: alter tablespace CTAS_NOARCH offline&lt;br /&gt;Sat Nov 05 00:34:40 2011&lt;br /&gt;Full restore complete of datafile 17 /home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_ctas_noa_7c850q6y_.dbf.  Elapsed time: 0:00:08&lt;br /&gt; checkpoint is 5479138&lt;br /&gt;Sat Nov 05 00:34:41 2011&lt;br /&gt;Checker run found 3 new persistent data failures&lt;br /&gt;Sat Nov 05 00:34:59 2011&lt;br /&gt;alter database recover datafile list clear&lt;br /&gt;Completed: alter database recover datafile list clear&lt;br /&gt;alter database recover if needed&lt;br /&gt;tablespace CTAS_NOARCH&lt;br /&gt;Media Recovery Start&lt;br /&gt;Serial Media Recovery started&lt;br /&gt;Recovery of Online Redo Log: Thread 1 Group 3 Seq 297 Reading mem 0&lt;br /&gt; Mem# 0: /home/oracle/app/oracle/oradata/orcl/redo03.log&lt;br /&gt;Media Recovery Complete (orcl)&lt;br /&gt;Completed: alter database recover if needed&lt;br /&gt;tablespace CTAS_NOARCH&lt;br /&gt;Sat Nov 05 00:35:13 2011&lt;br /&gt;alter tablespace CTAS_NOARCH online&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I then attempt to access the table :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt; -- query the table&lt;br /&gt;SQL&amp;gt; select count(*) from CTAS_NOARCH_TBL;&lt;br /&gt;select count(*) from CTAS_NOARCH_TBL&lt;br /&gt;                    *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-01578: ORACLE data block corrupted (file # 17, block # 131)&lt;br /&gt;ORA-01110: data file 17: '/home/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_ctas_noa_7c850q6y_.dbf'&lt;br /&gt;ORA-26040: Data block was loaded using the NOLOGGING option&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; spool off&lt;br /&gt;SQL&amp;gt; !oerr ora 26040&lt;br /&gt;26040, 00000, "Data block was loaded using the NOLOGGING option\n"&lt;br /&gt;//* Cause: Trying to access data in block that was loaded without&lt;br /&gt;//*        redo generation using the NOLOGGING/UNRECOVERABLE option&lt;br /&gt;//* Action: Drop the object containing the block.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, Oracle now finds that the blocks for the table have been loaded via a NOLOGGING operation.  I did not create the tablespace explicitly as NOLOGGING, I did not create the table as NOLOGGING.  Yet, the CTAS was (silently) executed as a NOLOGGING operation.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4092315801217533171?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4092315801217533171/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4092315801217533171' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4092315801217533171'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4092315801217533171'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/ctas-in-noarchivelog-database-is.html' title='CTAS in a NOARCHIVELOG database is a NOLOGGING operation'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-9017714593042771332</id><published>2011-11-04T15:15:00.001+08:00</published><updated>2011-11-04T15:16:55.645+08:00</updated><title type='text'>Index Organized Table(s)  -- IOT(s)</title><content type='html'>Here is a very useful series of &lt;a href="http://mwidlake.wordpress.com/2011/07/18/index-organized-tables-the-basics/"&gt;write-ups on Index Organized Table(s)&lt;/a&gt; by Martin Widlake.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-9017714593042771332?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/9017714593042771332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=9017714593042771332' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/9017714593042771332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/9017714593042771332'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/index-organized-tables-iots.html' title='Index Organized Table(s)  -- IOT(s)'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4829009022567654516</id><published>2011-11-02T23:17:00.002+08:00</published><updated>2011-11-02T23:25:00.919+08:00</updated><title type='text'>An ALTER USER to change password updates the timestamp of the password file</title><content type='html'>Apparently, upto 11.2.0.1, the password file is opened and verified and then closed when an ALTER USER ... IDENTIFIED BY ... is issued for any database account.&lt;div&gt;&lt;br /&gt;Here's a demo :&lt;br /&gt;&lt;pre&gt;[oracle@localhost ~]$ cd $ORACLE_HOME/dbs&lt;br /&gt;[oracle@localhost dbs]$ ls -l orapw*&lt;br /&gt;-rw-r----- 1 oracle oracle 1536 Jun 27 23:53 orapworcl&lt;br /&gt;[oracle@localhost dbs]$ date&lt;br /&gt;Wed Nov  2 23:12:27 SGT 2011&lt;br /&gt;[oracle@localhost dbs]$ sqlplus hemant/hemant&lt;br /&gt;&lt;br /&gt;SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 2 23:12:47 2011&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle.  All rights reserved.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Connected to:&lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production&lt;br /&gt;With the Partitioning, OLAP, Data Mining and Real Application Testing options&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create user TEST_A identified by TEST_A;&lt;br /&gt;&lt;br /&gt;User created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; !date&lt;br /&gt;Wed Nov  2 23:13:04 SGT 2011&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; !ls -l orapw*&lt;br /&gt;-rw-r----- 1 oracle oracle 1536 Jun 27 23:53 orapworcl&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter user TEST_A identified by TEST_A_PWD;&lt;br /&gt;&lt;br /&gt;User altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; !ls -l orapw*&lt;br /&gt;-rw-r----- 1 oracle oracle 1536 Nov  2 23:13 orapworcl&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Thus, a CREATE USER did not change the timestamp of the password file.  But an ALTER USER ... IDENTIFIED BY did change the timestamp.  However, the file doesn't really get updated because this user (TEST_A) is not a SYSDBA or SYSOPER user.&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; !date&lt;br /&gt;Wed Nov  2 23:16:59 SGT 2011&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; !cp -p orapworcl orapworcl.keep&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; !ls -l orapw*&lt;br /&gt;-rw-r----- 1 oracle oracle 1536 Nov  2 23:13 orapworcl&lt;br /&gt;-rw-r----- 1 oracle oracle 1536 Nov  2 23:13 orapworcl.keep&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter user TEST_A identified by TEST_A_NEW;&lt;br /&gt;&lt;br /&gt;User altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; !ls -l orapw*&lt;br /&gt;-rw-r----- 1 oracle oracle 1536 Nov  2 23:17 orapworcl&lt;br /&gt;-rw-r----- 1 oracle oracle 1536 Nov  2 23:13 orapworcl.keep&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; !diff orapworcl  orapworcl.keep&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Thus, although the timestamp of the password file did get updated, there was no real change to the file.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;See Oracle Support article "Timestamp on ORAPWD File Updated When Users' Password Changed [ID  312093.1]" for a description.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4829009022567654516?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4829009022567654516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4829009022567654516' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4829009022567654516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4829009022567654516'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/alter-user-to-change-password-updates.html' title='An ALTER USER to change password updates the timestamp of the password file'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-8435338803326102280</id><published>2011-11-01T13:05:00.002+08:00</published><updated>2011-11-01T13:07:56.719+08:00</updated><title type='text'>Handling Exceptions in PLSQL</title><content type='html'>Tom Kyte has repeatedly, repeatedly, repeatedly found fault with the usage of WHEN OTHERS -- particularly without a RAISE or RAISE_APPLICATION_ERROR.&lt;br /&gt;&lt;br /&gt;See his article &lt;a href="http://www.oracle.com/technetwork/issue-archive/2011/11-nov/o61asktom-512015.html"&gt;Why You Really Want to Let Exceptions Propagate&lt;/a&gt; (you need to scroll down the page) in the latest issue of Oracle Magazine.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-8435338803326102280?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/8435338803326102280/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=8435338803326102280' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/8435338803326102280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/8435338803326102280'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/11/handling-exceptions-in-plsql.html' title='Handling Exceptions in PLSQL'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-3494282289990482339</id><published>2011-10-24T23:48:00.004+08:00</published><updated>2011-10-26T11:09:17.061+08:00</updated><title type='text'>AIOUG : Sangam '11</title><content type='html'>&lt;a href="http://www.aioug.org/sangam11.php" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 154px; height: 159px;" src="http://3.bp.blogspot.com/-WjOqSlztODo/TqWJ2QLq9-I/AAAAAAAAC9Y/dqP7ex1jcmw/s1600/I_am_Speaking_at_Sangam11.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5667087271265499106" /&gt;&lt;/a&gt;&lt;br /&gt;A Reminder :  The &lt;a href="http://www.aioug.org/sangam11.php"&gt;AIOUG Sangam '11 Conference&lt;/a&gt;  09-10 December,  Bengaluru (Bangalore)&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-3494282289990482339?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/3494282289990482339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=3494282289990482339' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3494282289990482339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3494282289990482339'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/10/aioug-sangam-11.html' title='AIOUG : Sangam &apos;11'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-WjOqSlztODo/TqWJ2QLq9-I/AAAAAAAAC9Y/dqP7ex1jcmw/s72-c/I_am_Speaking_at_Sangam11.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-2126999360623635124</id><published>2011-10-20T23:15:00.002+08:00</published><updated>2011-10-20T23:25:00.672+08:00</updated><title type='text'>The impact of ASSM on Clustering of data  --  2</title><content type='html'>Revisiting &lt;a href="http://hemantoracledba.blogspot.com/2011/10/impact-of-assm-on-clustering-of-data.html"&gt;my earlier test on the same topic&lt;/a&gt;,  I add a change to "slow" down the operations.  The fetching of sequence values with the default cache was  so fast in the earlier test, that the three sessions that I manually invoked to execute concurrently did not show a real distribution of data.  The first session had retrieved very many sequence values and inserted rows before the second session had even started ... and the third session was "far behind" -- this was because my cycling through the 3 terminal windows and hitting the ENTER button to start the executions of the procedures was not fast enough.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, in this "twist" I deliberately set the sequences to NOCACHE, thus causing each INSERT to be much slower.  Now, there is a much higher degree of concurrency of inserts.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Remember : This experiment was to demonstrate how ASSM "distributes" rows across different blocks.  3 different sessions concurrently inserting in MSSM will be hitting a single free list but will likely be inserting across different blocks in ASSM.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, here is the test :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&amp;gt; connect / as sysdba&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- demo behaviour of ASSM with multiple sessions inserting concurrently&lt;br /&gt;SQL&amp;gt; -- data gets "distributed" to reduce block-contention&lt;br /&gt;SQL&amp;gt; -- but this affects the Clustering Factor !&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop tablespace ASSM_TBS including contents and datafiles;&lt;br /&gt;&lt;br /&gt;Tablespace dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create tablespace ASSM_TBS extent management local autoallocate segment space management auto;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; drop tablespace MSSM_TBS including contents and datafiles;&lt;br /&gt;&lt;br /&gt;Tablespace dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create tablespace MSSM_TBS extent management local autoallocate segment space management manual;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- grants required for stored procedures to access v$process, v$session, v$mystat&lt;br /&gt;SQL&amp;gt; grant select on v_$process to hemant;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; grant select on v_$session to hemant;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; grant select on v_$mystat to hemant;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- Reconnect as HEMANT&lt;br /&gt;SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- setup the Invoices table and PK index and sequence&lt;br /&gt;SQL&amp;gt; drop table ASSM_Table;&lt;br /&gt;drop table ASSM_Table&lt;br /&gt;          *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00942: table or view does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create table ASSM_Table (&lt;br /&gt; 2  invoice_id  number not null,&lt;br /&gt; 3  invoice_date date,&lt;br /&gt; 4  invoice_details  varchar2(50),&lt;br /&gt; 5  inserting_pid number)&lt;br /&gt; 6  tablespace ASSM_TBS&lt;br /&gt; 7  /&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create unique index ASSM_Table_PK on ASSM_Table(invoice_id) tablespace ASSM_TBS;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter table ASSM_Table add constraint ASSM_Table_PK primary key (invoice_id);&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; drop sequence ASSM_invoice_Seq ;&lt;br /&gt;&lt;br /&gt;Sequence dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create sequence ASSM_invoice_Seq start with 1 increment by 1 nocache ;&lt;br /&gt;&lt;br /&gt;Sequence created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop table MSSM_Table;&lt;br /&gt;drop table MSSM_Table&lt;br /&gt;          *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00942: table or view does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create table MSSM_Table (&lt;br /&gt; 2  invoice_id  number not null,&lt;br /&gt; 3  invoice_date date,&lt;br /&gt; 4  invoice_details  varchar2(50),&lt;br /&gt; 5  inserting_pid number)&lt;br /&gt; 6  tablespace MSSM_TBS&lt;br /&gt; 7  /&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create unique index MSSM_Table_PK on MSSM_Table(invoice_id) tablespace MSSM_TBS;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter table MSSM_Table add constraint MSSM_Table_PK primary key (invoice_id);&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; drop sequence MSSM_invoice_Seq ;&lt;br /&gt;&lt;br /&gt;Sequence dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create sequence MSSM_invoice_Seq start with 1 increment by 1 nocache;&lt;br /&gt;&lt;br /&gt;Sequence created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- create procedures that will simulate an application server&lt;br /&gt;SQL&amp;gt; -- or ETL engine that inserts 500 rows&lt;br /&gt;SQL&amp;gt; create or replace procedure populate_ASSM_Table&lt;br /&gt; 2  as&lt;br /&gt; 3  i  number;&lt;br /&gt; 4  begin&lt;br /&gt; 5  for i in 1..501&lt;br /&gt; 6  loop&lt;br /&gt; 7  insert into ASSM_Table&lt;br /&gt; 8  select ASSM_invoice_seq.nextval, sysdate+rownum/10000, rpad('A',40,'X'), pid&lt;br /&gt; 9  from&lt;br /&gt;10  v$process p, v$session s&lt;br /&gt;11  where p.addr=s.paddr&lt;br /&gt;12  and s.sid=(select sid from v$mystat where rownum=1)&lt;br /&gt;13  ;&lt;br /&gt;14  end loop;&lt;br /&gt;15  commit;&lt;br /&gt;16  end;&lt;br /&gt;17  /&lt;br /&gt;&lt;br /&gt;Procedure created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; create or replace procedure populate_MSSM_Table&lt;br /&gt; 2  as&lt;br /&gt; 3  i number;&lt;br /&gt; 4  begin&lt;br /&gt; 5  for i in 1..501&lt;br /&gt; 6  loop&lt;br /&gt; 7  insert into MSSM_Table&lt;br /&gt; 8  select MSSM_invoice_seq.nextval, sysdate+rownum/10000, rpad('A',40,'X'), pid&lt;br /&gt; 9  from&lt;br /&gt;10  v$process p, v$session s&lt;br /&gt;11  where p.addr=s.paddr&lt;br /&gt;12  and s.sid=(select sid from v$mystat where rownum=1)&lt;br /&gt;13  ;&lt;br /&gt;14  end loop;&lt;br /&gt;15  commit;&lt;br /&gt;16  end;&lt;br /&gt;17  /&lt;br /&gt;&lt;br /&gt;Procedure created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; REM  now run the procedures from three separate sessions&lt;br /&gt;SQL&amp;gt; pause .............. wait for the procedures to be executed&lt;br /&gt;.............. wait for the procedures to be executed&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- gather statistics on the tables and indexes&lt;br /&gt;SQL&amp;gt; exec dbms_Stats.gather_table_stats('','ASSM_TABLE',estimate_percent=&amp;gt;100,cascade=&amp;gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; exec dbms_Stats.gather_table_stats('','MSSM_TABLE',estimate_percent=&amp;gt;100,cascade=&amp;gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- view statistics on the tables and indexes&lt;br /&gt;SQL&amp;gt; select table_name, num_rows, blocks&lt;br /&gt; 2  from user_tables&lt;br /&gt; 3  where table_name in ('ASSM_TABLE','MSSM_TABLE')&lt;br /&gt; 4  order by 1&lt;br /&gt; 5  /&lt;br /&gt;&lt;br /&gt;TABLE_NAME                       NUM_ROWS     BLOCKS                                                         &lt;br /&gt;------------------------------ ---------- ----------                                                         &lt;br /&gt;ASSM_TABLE                           1503         13                                                         &lt;br /&gt;MSSM_TABLE                           1503         15                                                         &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select index_name, num_rows, blevel, leaf_blocks, clustering_factor&lt;br /&gt; 2  from user_indexes&lt;br /&gt; 3  where index_name in ('ASSM_TABLE_PK','MSSM_TABLE_PK')&lt;br /&gt; 4  order by 1&lt;br /&gt; 5  /&lt;br /&gt;&lt;br /&gt;INDEX_NAME                       NUM_ROWS     BLEVEL LEAF_BLOCKS CLUSTERING_FACTOR                           &lt;br /&gt;------------------------------ ---------- ---------- ----------- -----------------                           &lt;br /&gt;ASSM_TABLE_PK                        1503          1           4               302                           &lt;br /&gt;MSSM_TABLE_PK                        1503          1           3                17                           &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- view the number of distinct blocks&lt;br /&gt;SQL&amp;gt; select inserting_pid,count(distinct(dbms_rowid.rowid_block_number(rowid)))&lt;br /&gt; 2  from ASSM_TABLE&lt;br /&gt; 3  group by inserting_pid&lt;br /&gt; 4  order by 1&lt;br /&gt; 5  /&lt;br /&gt;&lt;br /&gt;INSERTING_PID COUNT(DISTINCT(DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)))                                          &lt;br /&gt;------------- -----------------------------------------------------                                          &lt;br /&gt;          23                                                     6                                          &lt;br /&gt;          29                                                     7                                          &lt;br /&gt;          30                                                     5                                          &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select inserting_pid,count(distinct(dbms_rowid.rowid_block_number(rowid)))&lt;br /&gt; 2  from MSSM_TABLE&lt;br /&gt; 3  group by inserting_pid&lt;br /&gt; 4  order by 1&lt;br /&gt; 5  /&lt;br /&gt;&lt;br /&gt;INSERTING_PID COUNT(DISTINCT(DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)))                                          &lt;br /&gt;------------- -----------------------------------------------------                                          &lt;br /&gt;          23                                                     7                                          &lt;br /&gt;          29                                                     6                                          &lt;br /&gt;          30                                                     8                                          &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Notice how the number of blocks for the table and for each inserting process is generally the same for the ASSM table and the MSSM table.  But the CLUSTERING_FACTOR is now significantly higher in the ASSM table.&lt;br /&gt;In MSSM, each new row (higher sequence value) almost always went in the same block as the previous row, except when the block was full.  Thus a table with 15 blocks has a CLUSTERING_FACTOR of only 17.  These rows are very well clustered.&lt;br /&gt;In ASSM, on the other hand, the CLUSTERING_FACTOR is 302 !  Much higher spread across blocks.  Given a row for INVOICE_ID (i.e. the sequence-based value) 'n', the likelihood of the row for INVOICE_ID 'n+1' being in the same block is much lower in ASSM than in MSSM.  An Index Range Scan will be more "expensive" in the ASSM Table.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-2126999360623635124?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/2126999360623635124/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=2126999360623635124' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2126999360623635124'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2126999360623635124'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/10/impact-of-assm-on-clustering-of-data-2.html' title='The impact of ASSM on Clustering of data  --  2'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-2017733600143286210</id><published>2011-10-17T23:10:00.006+08:00</published><updated>2011-10-18T00:14:08.537+08:00</updated><title type='text'>DBMS_REDEFINITION to redefine a Partition  -- and the impact of deferred_segment_creation</title><content type='html'>During a &lt;a href="https://forums.oracle.com/forums/thread.jspa?forumID=75&amp;amp;threadID=2296770"&gt;forums discussion on START_REDEF&lt;/a&gt;, I created test cases in 10.2 and 11.2 to test DBMS_REDEFINITION to redefine a Partition (instead of using ALTER TABLE .... EXCHANGE PARTITION).&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If there is a Primary Key, normally, I should use options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_PK  However, if I use options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_ROWID, Oracle attempts to create another Unique Index.  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here's the peculiarity.  If I do not have any row present in the partition (so it is a segmentless partition), the FINISH_REDEF fails with an Object deadlock  :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select * from v$version;&lt;br /&gt;&lt;br /&gt;BANNER                                                                                                      &lt;br /&gt;--------------------------------------------------------------------------------                            &lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production                                      &lt;br /&gt;PL/SQL Release 11.2.0.1.0 - Production                                                                      &lt;br /&gt;CORE    11.2.0.1.0      Production                                                                                  &lt;br /&gt;TNS for Linux: Version 11.2.0.1.0 - Production                                                              &lt;br /&gt;NLSRTL Version 11.2.0.1.0 - Production                                                                      &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; show parameter deferred;&lt;br /&gt;&lt;br /&gt;NAME                                 TYPE        VALUE                                                      &lt;br /&gt;------------------------------------ ----------- ------------------------------                             &lt;br /&gt;deferred_segment_creation            boolean     TRUE                                                       &lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop materialized view int_salestable;&lt;br /&gt;drop materialized view int_salestable&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-12003: materialized view "HEMANT"."INT_SALESTABLE" does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE salestable;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  TABLESPACE users&lt;br /&gt;8  PARTITION BY RANGE(s_saledate)&lt;br /&gt;9  (PARTITION sal03q1 VALUES LESS THAN (TO_DATE('01-APR-2003', 'DD-MON-YYYY')),&lt;br /&gt;10  PARTITION sal03q2 VALUES LESS THAN (TO_DATE('01-JUL-2003', 'DD-MON-YYYY')),&lt;br /&gt;11  PARTITION sal03q3 VALUES LESS THAN (TO_DATE('01-OCT-2003', 'DD-MON-YYYY')),&lt;br /&gt;12  PARTITION sal03q4 VALUES LESS THAN (TO_DATE('01-JAN-2004', 'DD-MON-YYYY')));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX sales_index ON salestable(s_saledate, s_saleid, s_custid) logging LOCAL;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        USERS                                                                        &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        USERS                                                                        &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE int_salestable ;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE int_salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  tablespace example;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table int_salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX int_sales_index ON int_salestable&lt;br /&gt;2  (s_saledate, s_saleid, s_custid)&lt;br /&gt;3  logging&lt;br /&gt;4  TABLESPACE example;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.CAN_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  tname =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_ROWID,&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.START_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  col_mapping =&amp;gt; NULL,&lt;br /&gt;7  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_ROWID,&lt;br /&gt;8  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;9  END;&lt;br /&gt;10  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.FINISH_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;BEGIN&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-42012: error occurred while completing the redefinition&lt;br /&gt;ORA-04020: deadlock detected while trying to lock object HEMANT.INT_SALESTABLE&lt;br /&gt;ORA-06512: at "SYS.DBMS_REDEFINITION", line 78&lt;br /&gt;ORA-06512: at "SYS.DBMS_REDEFINITION", line 1680&lt;br /&gt;ORA-06512: at line 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        USERS                                                                        &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        USERS                                                                        &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note the usage of CONS_USE_ROWID.&lt;br /&gt;&lt;br /&gt;However, if the partition does have a row present, i.e it does have a segment created, then the FINISH_REDEF can succeed.&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select * from v$version;&lt;br /&gt;&lt;br /&gt;BANNER                                                                                                      &lt;br /&gt;--------------------------------------------------------------------------------                            &lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production                                      &lt;br /&gt;PL/SQL Release 11.2.0.1.0 - Production                                                                      &lt;br /&gt;CORE    11.2.0.1.0      Production                                                                                  &lt;br /&gt;TNS for Linux: Version 11.2.0.1.0 - Production                                                              &lt;br /&gt;NLSRTL Version 11.2.0.1.0 - Production                                                                      &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; show parameter deferred;&lt;br /&gt;&lt;br /&gt;NAME                                 TYPE        VALUE                                                      &lt;br /&gt;------------------------------------ ----------- ------------------------------                             &lt;br /&gt;deferred_segment_creation            boolean     TRUE                                                       &lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop materialized view int_salestable;&lt;br /&gt;&lt;br /&gt;Materialized view dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE salestable;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  TABLESPACE users&lt;br /&gt;8  PARTITION BY RANGE(s_saledate)&lt;br /&gt;9  (PARTITION sal03q1 VALUES LESS THAN (TO_DATE('01-APR-2003', 'DD-MON-YYYY')),&lt;br /&gt;10  PARTITION sal03q2 VALUES LESS THAN (TO_DATE('01-JUL-2003', 'DD-MON-YYYY')),&lt;br /&gt;11  PARTITION sal03q3 VALUES LESS THAN (TO_DATE('01-OCT-2003', 'DD-MON-YYYY')),&lt;br /&gt;12  PARTITION sal03q4 VALUES LESS THAN (TO_DATE('01-JAN-2004', 'DD-MON-YYYY')));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; insert into salestable partition (sal03q1) values (101,to_date('01-JAN-2003','DD-MON-YYYY'),1,2000);&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX sales_index ON salestable(s_saledate, s_saleid, s_custid) logging LOCAL;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        USERS                                                                        &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        USERS                                                                        &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE int_salestable ;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE int_salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  tablespace example;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table int_salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX int_sales_index ON int_salestable&lt;br /&gt;2  (s_saledate, s_saleid, s_custid)&lt;br /&gt;3  logging&lt;br /&gt;4  TABLESPACE example;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.CAN_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  tname =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_ROWID,&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.START_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  col_mapping =&amp;gt; NULL,&lt;br /&gt;7  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_ROWID,&lt;br /&gt;8  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;9  END;&lt;br /&gt;10  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.FINISH_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        EXAMPLE                                                                      &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        EXAMPLE                                                                      &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Well... the next thing is to test without deferred_segment_creation.  This should succeed.&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select * from v$version;&lt;br /&gt;&lt;br /&gt;BANNER                                                                                                      &lt;br /&gt;--------------------------------------------------------------------------------                            &lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production                                      &lt;br /&gt;PL/SQL Release 11.2.0.1.0 - Production                                                                      &lt;br /&gt;CORE    11.2.0.1.0      Production                                                                                  &lt;br /&gt;TNS for Linux: Version 11.2.0.1.0 - Production                                                              &lt;br /&gt;NLSRTL Version 11.2.0.1.0 - Production                                                                      &lt;br /&gt;&lt;br /&gt;SQL&amp;gt; show parameter deferred;&lt;br /&gt;&lt;br /&gt;NAME                                 TYPE        VALUE                                                      &lt;br /&gt;------------------------------------ ----------- ------------------------------                             &lt;br /&gt;deferred_segment_creation            boolean     TRUE                                                       &lt;br /&gt;SQL&amp;gt; alter session set deferred_segment_creation=FALSE;&lt;br /&gt;&lt;br /&gt;Session altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop materialized view int_salestable;&lt;br /&gt;drop materialized view int_salestable&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-12003: materialized view "HEMANT"."INT_SALESTABLE" does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE salestable;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  TABLESPACE users&lt;br /&gt;8  PARTITION BY RANGE(s_saledate)&lt;br /&gt;9  (PARTITION sal03q1 VALUES LESS THAN (TO_DATE('01-APR-2003', 'DD-MON-YYYY')),&lt;br /&gt;10  PARTITION sal03q2 VALUES LESS THAN (TO_DATE('01-JUL-2003', 'DD-MON-YYYY')),&lt;br /&gt;11  PARTITION sal03q3 VALUES LESS THAN (TO_DATE('01-OCT-2003', 'DD-MON-YYYY')),&lt;br /&gt;12  PARTITION sal03q4 VALUES LESS THAN (TO_DATE('01-JAN-2004', 'DD-MON-YYYY')));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX sales_index ON salestable(s_saledate, s_saleid, s_custid) logging LOCAL;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        USERS                                                                        &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        USERS                                                                        &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE int_salestable ;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE int_salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  tablespace example;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table int_salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX int_sales_index ON int_salestable&lt;br /&gt;2  (s_saledate, s_saleid, s_custid)&lt;br /&gt;3  logging&lt;br /&gt;4  TABLESPACE example;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.CAN_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  tname =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_ROWID,&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.START_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  col_mapping =&amp;gt; NULL,&lt;br /&gt;7  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_ROWID,&lt;br /&gt;8  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;9  END;&lt;br /&gt;10  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.FINISH_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        EXAMPLE                                                                      &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME                                                              &lt;br /&gt;------------------------------ ------------------------------                                               &lt;br /&gt;SAL03Q1                        EXAMPLE                                                                      &lt;br /&gt;SAL03Q2                        USERS                                                                        &lt;br /&gt;SAL03Q3                        USERS                                                                        &lt;br /&gt;SAL03Q4                        USERS                                                                        &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, in 11.2, with deferred segments, CONS_USE_ROWID results in an object deadlock for an empty partition.  What if I use CONS_USE_PK ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select * from v$version;&lt;br /&gt;&lt;br /&gt;BANNER&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production&lt;br /&gt;PL/SQL Release 11.2.0.1.0 - Production&lt;br /&gt;CORE    11.2.0.1.0      Production&lt;br /&gt;TNS for Linux: Version 11.2.0.1.0 - Production&lt;br /&gt;NLSRTL Version 11.2.0.1.0 - Production&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; show parameter deferred;&lt;br /&gt;&lt;br /&gt;NAME                                 TYPE        VALUE&lt;br /&gt;------------------------------------ ----------- ------------------------------&lt;br /&gt;deferred_segment_creation            boolean     TRUE&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop materialized view int_salestable;&lt;br /&gt;&lt;br /&gt;Materialized view dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE salestable;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  TABLESPACE users&lt;br /&gt;8  PARTITION BY RANGE(s_saledate)&lt;br /&gt;9  (PARTITION sal03q1 VALUES LESS THAN (TO_DATE('01-APR-2003', 'DD-MON-YYYY')),&lt;br /&gt;10  PARTITION sal03q2 VALUES LESS THAN (TO_DATE('01-JUL-2003', 'DD-MON-YYYY')),&lt;br /&gt;11  PARTITION sal03q3 VALUES LESS THAN (TO_DATE('01-OCT-2003', 'DD-MON-YYYY')),&lt;br /&gt;12  PARTITION sal03q4 VALUES LESS THAN (TO_DATE('01-JAN-2004', 'DD-MON-YYYY')));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX sales_index ON salestable(s_saledate, s_saleid, s_custid) logging LOCAL;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME&lt;br /&gt;------------------------------ ------------------------------&lt;br /&gt;SAL03Q1                        USERS&lt;br /&gt;SAL03Q2                        USERS&lt;br /&gt;SAL03Q3                        USERS&lt;br /&gt;SAL03Q4                        USERS&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME&lt;br /&gt;------------------------------ ------------------------------&lt;br /&gt;SAL03Q1                        USERS&lt;br /&gt;SAL03Q2                        USERS&lt;br /&gt;SAL03Q3                        USERS&lt;br /&gt;SAL03Q4                        USERS&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE int_salestable ;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE int_salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  tablespace example;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table int_salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX int_sales_index ON int_salestable&lt;br /&gt;2  (s_saledate, s_saleid, s_custid)&lt;br /&gt;3  logging&lt;br /&gt;4  TABLESPACE example;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.CAN_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  tname =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_PK,&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.START_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  col_mapping =&amp;gt; NULL,&lt;br /&gt;7  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_PK,&lt;br /&gt;8  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;9  END;&lt;br /&gt;10  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.FINISH_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;BEGIN&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-42012: error occurred while completing the redefinition&lt;br /&gt;ORA-04020: deadlock detected while trying to lock object HEMANT.INT_SALESTABLE&lt;br /&gt;ORA-06512: at "SYS.DBMS_REDEFINITION", line 78&lt;br /&gt;ORA-06512: at "SYS.DBMS_REDEFINITION", line 1680&lt;br /&gt;ORA-06512: at line 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME&lt;br /&gt;------------------------------ ------------------------------&lt;br /&gt;SAL03Q1                        USERS&lt;br /&gt;SAL03Q2                        USERS&lt;br /&gt;SAL03Q3                        USERS&lt;br /&gt;SAL03Q4                        USERS&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME&lt;br /&gt;------------------------------ ------------------------------&lt;br /&gt;SAL03Q1                        USERS&lt;br /&gt;SAL03Q2                        USERS&lt;br /&gt;SAL03Q3                        USERS&lt;br /&gt;SAL03Q4                        USERS&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then, I retry disabling deferred_segment_creation, so as to force a segment to be created, and use CONS_USE_PK :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select * from v$version;&lt;br /&gt;&lt;br /&gt;BANNER&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production&lt;br /&gt;PL/SQL Release 11.2.0.1.0 - Production&lt;br /&gt;CORE    11.2.0.1.0      Production&lt;br /&gt;TNS for Linux: Version 11.2.0.1.0 - Production&lt;br /&gt;NLSRTL Version 11.2.0.1.0 - Production&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; show parameter deferred;&lt;br /&gt;&lt;br /&gt;NAME                                 TYPE        VALUE&lt;br /&gt;------------------------------------ ----------- ------------------------------&lt;br /&gt;deferred_segment_creation            boolean     TRUE&lt;br /&gt;SQL&amp;gt; alter session set deferred_segment_creation=FALSE;&lt;br /&gt;&lt;br /&gt;Session altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop materialized view int_salestable;&lt;br /&gt;&lt;br /&gt;Materialized view dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE salestable;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  TABLESPACE users&lt;br /&gt;8  PARTITION BY RANGE(s_saledate)&lt;br /&gt;9  (PARTITION sal03q1 VALUES LESS THAN (TO_DATE('01-APR-2003', 'DD-MON-YYYY')),&lt;br /&gt;10  PARTITION sal03q2 VALUES LESS THAN (TO_DATE('01-JUL-2003', 'DD-MON-YYYY')),&lt;br /&gt;11  PARTITION sal03q3 VALUES LESS THAN (TO_DATE('01-OCT-2003', 'DD-MON-YYYY')),&lt;br /&gt;12  PARTITION sal03q4 VALUES LESS THAN (TO_DATE('01-JAN-2004', 'DD-MON-YYYY')));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX sales_index ON salestable(s_saledate, s_saleid, s_custid) logging LOCAL;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME&lt;br /&gt;------------------------------ ------------------------------&lt;br /&gt;SAL03Q1                        USERS&lt;br /&gt;SAL03Q2                        USERS&lt;br /&gt;SAL03Q3                        USERS&lt;br /&gt;SAL03Q4                        USERS&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME&lt;br /&gt;------------------------------ ------------------------------&lt;br /&gt;SAL03Q1                        USERS&lt;br /&gt;SAL03Q2                        USERS&lt;br /&gt;SAL03Q3                        USERS&lt;br /&gt;SAL03Q4                        USERS&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop TABLE int_salestable ;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE TABLE int_salestable&lt;br /&gt;2  (s_saleid NUMBER,&lt;br /&gt;3  s_saledate DATE,&lt;br /&gt;4  s_custid NUMBER,&lt;br /&gt;5  s_totalprice NUMBER)&lt;br /&gt;6  logging&lt;br /&gt;7  tablespace example;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; alter table int_salestable modify s_saleid number primary key;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; CREATE INDEX int_sales_index ON int_salestable&lt;br /&gt;2  (s_saledate, s_saleid, s_custid)&lt;br /&gt;3  logging&lt;br /&gt;4  TABLESPACE example;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.CAN_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  tname =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_PK,&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.START_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  col_mapping =&amp;gt; NULL,&lt;br /&gt;7  options_flag =&amp;gt; DBMS_REDEFINITION.CONS_USE_PK,&lt;br /&gt;8  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;9  END;&lt;br /&gt;10  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; BEGIN&lt;br /&gt;2  DBMS_REDEFINITION.FINISH_REDEF_TABLE(&lt;br /&gt;3  uname =&amp;gt; 'HEMANT',&lt;br /&gt;4  orig_table =&amp;gt; 'SALESTABLE',&lt;br /&gt;5  int_table =&amp;gt; 'INT_SALESTABLE',&lt;br /&gt;6  part_name =&amp;gt; 'SAL03Q1');&lt;br /&gt;7  END;&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_tab_partitions&lt;br /&gt;2  where table_name = 'SALESTABLE' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME&lt;br /&gt;------------------------------ ------------------------------&lt;br /&gt;SAL03Q1                        EXAMPLE&lt;br /&gt;SAL03Q2                        USERS&lt;br /&gt;SAL03Q3                        USERS&lt;br /&gt;SAL03Q4                        USERS&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select partition_name, tablespace_name from user_ind_partitions&lt;br /&gt;2  where index_name = 'SALES_INDEX' order by partition_name&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME&lt;br /&gt;------------------------------ ------------------------------&lt;br /&gt;SAL03Q1                        EXAMPLE&lt;br /&gt;SAL03Q2                        USERS&lt;br /&gt;SAL03Q3                        USERS&lt;br /&gt;SAL03Q4                        USERS&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This succeeds as expected.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Conclusion :&lt;/span&gt; If a partition that is to be "exchanged" via DBMS_REDEFINITION is empty and deferred_segment_creation is enabled in 11.2, an ORA-4020 Object Deadlock error occurs when attempting to FINISH_REDEF.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Question : Is this a valid conclusion ?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-2017733600143286210?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/2017733600143286210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=2017733600143286210' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2017733600143286210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2017733600143286210'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/10/dbmsredefinition-to-redefine-partition.html' title='DBMS_REDEFINITION to redefine a Partition  -- and the impact of deferred_segment_creation'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-1532500004893832390</id><published>2011-10-08T22:17:00.003+08:00</published><updated>2011-10-20T23:27:14.871+08:00</updated><title type='text'>The impact of ASSM on Clustering of data</title><content type='html'>Automatic Segment Space Management ("ASSM") is designed to reduce block-level contention by multiple sessions concurrently attempting INSERTs by using a bitmap to identify blocks that are on the FreeList.  The FreeList is accessed by sessions attempting to insert a row in a table when they need to identify "candidate" blocks.  In Manual Segment Space Management ("MSSM"), it is the block-level storage parameter PCTUSED that is a determinant for when a block "enters" and "exits" the freelist.  (Note : PCTFREE plays the same role in in MSSM and ASSM -- determining the "reserved" free space in a block that may be used for UPDATEs to rows in the block.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is demonstration of the impact of ASSM on the clustering of data.  I use a Unique Index based on a Sequence to ensure that every new row has an incremented value.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- demo behaviour of ASSM with multiple sessions inserting concurrently&lt;br /&gt;SQL&amp;gt; -- data gets "distributed" to reduce block-contention&lt;br /&gt;SQL&amp;gt; -- but this affects the Clustering Factor !&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I start with two tablespaces : ASSM and MSSM and the target tables and indexes :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&amp;gt; drop tablespace ASSM_TBS including contents and datafiles;&lt;br /&gt;drop tablespace ASSM_TBS including contents and datafiles&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00959: tablespace 'ASSM_TBS' does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create tablespace ASSM_TBS extent management local autoallocate segment space management auto;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; drop tablespace MSSM_TBS including contents and datafiles;&lt;br /&gt;drop tablespace MSSM_TBS including contents and datafiles&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00959: tablespace 'MSSM_TBS' does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create tablespace MSSM_TBS extent management local autoallocate segment space management manual;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- grants required for stored procedures to access v$process, v$session, v$mystat&lt;br /&gt;SQL&amp;gt; grant select on v_$process to hemant;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; grant select on v_$session to hemant;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; grant select on v_$mystat to hemant;&lt;br /&gt;&lt;br /&gt;Grant succeeded.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- Reconnect as HEMANT&lt;br /&gt;SQL&amp;gt; connect hemant/hemant&lt;br /&gt;Connected.&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- setup the Invoices table and PK index and sequence&lt;br /&gt;SQL&amp;gt; drop table ASSM_Table;&lt;br /&gt;drop table ASSM_Table&lt;br /&gt;          *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00942: table or view does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create table ASSM_Table (&lt;br /&gt; 2  invoice_id  number not null,&lt;br /&gt; 3  invoice_date date,&lt;br /&gt; 4  invoice_details  varchar2(50),&lt;br /&gt; 5  inserting_pid number)&lt;br /&gt; 6  tablespace ASSM_TBS&lt;br /&gt; 7  /&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create unique index ASSM_Table_PK on ASSM_Table(invoice_id) tablespace ASSM_TBS;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter table ASSM_Table add constraint ASSM_Table_PK primary key (invoice_id);&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; drop sequence ASSM_invoice_Seq ;&lt;br /&gt;drop sequence ASSM_invoice_Seq&lt;br /&gt;             *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-02289: sequence does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create sequence ASSM_invoice_Seq start with 1 increment by 1;&lt;br /&gt;&lt;br /&gt;Sequence created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop table MSSM_Table;&lt;br /&gt;drop table MSSM_Table&lt;br /&gt;          *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00942: table or view does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create table MSSM_Table (&lt;br /&gt; 2  invoice_id  number not null,&lt;br /&gt; 3  invoice_date date,&lt;br /&gt; 4  invoice_details  varchar2(50),&lt;br /&gt; 5  inserting_pid number)&lt;br /&gt; 6  tablespace MSSM_TBS&lt;br /&gt; 7  /&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create unique index MSSM_Table_PK on MSSM_Table(invoice_id) tablespace MSSM_TBS;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter table MSSM_Table add constraint MSSM_Table_PK primary key (invoice_id);&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; drop sequence MSSM_invoice_Seq ;&lt;br /&gt;drop sequence MSSM_invoice_Seq&lt;br /&gt;             *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-02289: sequence does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create sequence MSSM_invoice_Seq start with 1 increment by 1;&lt;br /&gt;&lt;br /&gt;Sequence created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I then create two procedures that I will use to simulate an application server / ETL engine that inserts 50,000 rows but uses the Sequence to generate Primary Key.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&amp;gt; -- create procedures that will simulate an application server&lt;br /&gt;SQL&amp;gt; -- or ETL engine that inserts 50000 rows&lt;br /&gt;SQL&amp;gt; create or replace procedure populate_ASSM_Table&lt;br /&gt; 2  as&lt;br /&gt; 3  i  number;&lt;br /&gt; 4  begin&lt;br /&gt; 5  for i in 1..50001&lt;br /&gt; 6  loop&lt;br /&gt; 7  insert into ASSM_Table&lt;br /&gt; 8  select ASSM_invoice_seq.nextval, sysdate+rownum/10000, rpad('A',40,'X'), pid&lt;br /&gt; 9  from&lt;br /&gt;10  v$process p, v$session s&lt;br /&gt;11  where p.addr=s.paddr&lt;br /&gt;12  and s.sid=(select sid from v$mystat where rownum=1)&lt;br /&gt;13  ;&lt;br /&gt;14  end loop;&lt;br /&gt;15  commit;&lt;br /&gt;16  end;&lt;br /&gt;17  /&lt;br /&gt;&lt;br /&gt;Procedure created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create or replace procedure populate_MSSM_Table&lt;br /&gt; 2  as&lt;br /&gt; 3  i number;&lt;br /&gt; 4  begin&lt;br /&gt; 5  for i in 1..50001&lt;br /&gt; 6  loop&lt;br /&gt; 7  insert into MSSM_Table&lt;br /&gt; 8  select MSSM_invoice_seq.nextval, sysdate+rownum/10000, rpad('A',40,'X'), pid&lt;br /&gt; 9  from&lt;br /&gt;10  v$process p, v$session s&lt;br /&gt;11  where p.addr=s.paddr&lt;br /&gt;12  and s.sid=(select sid from v$mystat where rownum=1)&lt;br /&gt;13  ;&lt;br /&gt;14  end loop;&lt;br /&gt;15  commit;&lt;br /&gt;16  end;&lt;br /&gt;17  /&lt;br /&gt;&lt;br /&gt;Procedure created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I then wait for the procedures to be executed by 3 sessions to simulate 3 concurrent sessions inserting 50,000 rows each :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; REM  now run the procedures from three separate sessions&lt;br /&gt;SQL&amp;gt; pause .............. wait for the procedures to be executed&lt;br /&gt;.............. wait for the procedures to be executed&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note :  The two procedures are executed from 3 sessions (i.e. the three sessions first execute Populate_ASSM_Table, followed by an execution of Populate_MSSM_Table). The invocations of the procedures are almost concurrent as I execute them from SQL sessions in 3 terminal windows.&lt;br /&gt;&lt;br /&gt;Once the executions are completed, I gather and review statistics for the two tables : the one in the ASSM Tablespace and the other in the MSSM Tablespace.&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; -- gather statistics on the tables and indexes&lt;br /&gt;SQL&amp;gt; exec dbms_Stats.gather_table_stats('','ASSM_TABLE',estimate_percent=&amp;gt;100,cascade=&amp;gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; exec dbms_Stats.gather_table_stats('','MSSM_TABLE',estimate_percent=&amp;gt;100,cascade=&amp;gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- view statistics on the tables and indexes&lt;br /&gt;SQL&amp;gt; select table_name, num_rows, blocks&lt;br /&gt; 2  from user_tables&lt;br /&gt; 3  where table_name in ('ASSM_TABLE','MSSM_TABLE')&lt;br /&gt; 4  order by 1&lt;br /&gt; 5  /&lt;br /&gt;&lt;br /&gt;TABLE_NAME                       NUM_ROWS     BLOCKS&lt;br /&gt;------------------------------ ---------- ----------&lt;br /&gt;ASSM_TABLE                         150003       1378&lt;br /&gt;MSSM_TABLE                         150003       1294&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select index_name, num_rows, blevel, leaf_blocks, clustering_factor&lt;br /&gt; 2  from user_indexes&lt;br /&gt; 3  where index_name in ('ASSM_TABLE_PK','MSSM_TABLE_PK')&lt;br /&gt; 4  order by 1&lt;br /&gt; 5  /&lt;br /&gt;&lt;br /&gt;INDEX_NAME                       NUM_ROWS     BLEVEL LEAF_BLOCKS CLUSTERING_FACTOR&lt;br /&gt;------------------------------ ---------- ---------- ----------- -----------------&lt;br /&gt;ASSM_TABLE_PK                      150003          1         341              5729&lt;br /&gt;MSSM_TABLE_PK                      150003          1         334              1588&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Since I have run GATHER_TABLE_STATS, cascade=&amp;gt;TRUE, the CLUSTERING_FACTOR truly represents the distribution of the rows.  Thus, after reading the row for INVOICE_ID 'n', the likelihood of INVOICE_ID 'n+1' being in the same block is much better in the MSSM_Table than in the ASSM_Table. &lt;br /&gt;&lt;br /&gt;Now, here's a quiz question.  Note the count of distinct blocks for each inserting Process.  Why is the count of distinct blocks actually much higher for the MSSM Table ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; -- view the number of distinct blocks&lt;br /&gt;SQL&amp;gt; select inserting_pid,count(distinct(dbms_rowid.rowid_block_number(rowid)))&lt;br /&gt; 2  from ASSM_TABLE&lt;br /&gt; 3  group by inserting_pid&lt;br /&gt; 4  order by 1&lt;br /&gt; 5  /&lt;br /&gt;&lt;br /&gt;INSERTING_PID COUNT(DISTINCT(DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)))&lt;br /&gt;------------- -----------------------------------------------------&lt;br /&gt;          28                                                   622&lt;br /&gt;          29                                                   711&lt;br /&gt;          30                                                   666&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select inserting_pid,count(distinct(dbms_rowid.rowid_block_number(rowid)))&lt;br /&gt; 2  from MSSM_TABLE&lt;br /&gt; 3  group by inserting_pid&lt;br /&gt; 4  order by 1&lt;br /&gt; 5  /&lt;br /&gt;&lt;br /&gt;INSERTING_PID COUNT(DISTINCT(DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)))&lt;br /&gt;------------- -----------------------------------------------------&lt;br /&gt;          28                                                  1269&lt;br /&gt;          29                                                  1290              &lt;br /&gt;          30                                                  1273              &lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;(Note : Each tablespace is only 1 datafile, so we need not consider FILE_ID when evaluating the BLOCK_NUMBERs).&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;div&gt;&lt;b&gt;UPDATE :&lt;/b&gt; See the &lt;a href="http://hemantoracledba.blogspot.com/2011/10/impact-of-assm-on-clustering-of-data-2.html"&gt;test repeated&lt;/a&gt; with the distribution of INVOICE_IDs across multiple blocks (i.e. poorly clustered) in ASSM on &lt;a href="http://hemantoracledba.blogspot.com/2011/10/impact-of-assm-on-clustering-of-data-2.html"&gt;20-Oct&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-1532500004893832390?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/1532500004893832390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=1532500004893832390' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1532500004893832390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1532500004893832390'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/10/impact-of-assm-on-clustering-of-data.html' title='The impact of ASSM on Clustering of data'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-5493653796483300394</id><published>2011-10-04T22:51:00.002+08:00</published><updated>2011-10-04T22:55:10.448+08:00</updated><title type='text'>Controlfiles : Number and Size</title><content type='html'>A forums thread "&lt;a href="https://forums.oracle.com/forums/thread.jspa?threadID=2293667&amp;amp;tstart=0"&gt;Maximum number of Control Files&lt;/a&gt;"  allowed me to express my opinions about why, for very practical reasons, Oracle does not allow very many multiplexed copies of the controlfile and why the controlfile is "limited" in size.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here are my two responses :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;On the "maximum number of control files" :&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;You have to consider how Oracle uses the control file.&lt;br /&gt;Logically it is one single controlfile multiplexed 'N' times.   Therefore, each physical copy has to be an exact mirror of every other  copy (just as every member of a log group is a mirror of other members  in the same group).&lt;br /&gt;&lt;br /&gt;When does Oracle update the controlfile  ? Very frequently !  When a log  switch occurs, when ARCH needs to add information about an archived  file, when datafiles are added, when direct path operations take place,  when RMAN creates backuppieces etc ....&lt;br /&gt;Since the multiplexed controlfiles have to be mirrors, Oracle has to  actually update every controlfile precisely. It has to lock the  controlfile.  If you seen 'enq : CF contention' waits and/or read  threads and bugs relating to this you'd have seen the impact of this.  The default CF enqueue is 900seconds. Database instances have been known  to crash when the CF enqueue is held too long by one process while  another background is attempting to update the controlfile.&lt;br /&gt;If you have multiplexed the controlfile 12 times, the enqueue has to be  held until Oracle is sure that all 12 copies have been written to the  OS.&lt;br /&gt;&lt;br /&gt;Essentially : the controlfile is a point of serialisation.  Too many copies and the serialisation can be a severe constraint.&lt;br /&gt;&lt;br /&gt;Also when there are multiple controlfile "copies" some of them might  just happen to be on "slower" disks.  In such a case, controlfile  updates become as slow as the slowest disk !&lt;br /&gt;&lt;br /&gt;So, rather than a "technical constraint" there is a real-world constraint.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;On the "limited size of the control file" :&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Think in terms of how the controlfile can be backed up ...&lt;br /&gt;&lt;br /&gt;Why did Oracle never allow User-Managed backups of controlfiles using OS  commands like "cp" or "tar" or "cpio"  ?  Datafiles can be backed up  (after an ALTER DATABASE / TABLESPACE BEGIN BACKUP) using such commands  even though these may well use a block size of 512bytes or 1KB or 4KB --  a block size other than the database block size.  The datafiles are  "protected" from fractured block scenarios by capturing block updates in  the redo stream.  Unfortunately, controlfile  updates cannot be so  protected.  A controlfile copy has to be an "all or nothing" operation.   That is why Oracle provided the ALTER DATABASE BACKUP CONTROLFILE TO  'filename'  command -- it actually "locks" the controlfile while it is  being backed up to the destination.  An excessively large controlfile  would take very long to backup and would mean that it would be locked  for that duration.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-5493653796483300394?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/5493653796483300394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=5493653796483300394' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5493653796483300394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5493653796483300394'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/10/controlfiles-number-and-size.html' title='Controlfiles : Number and Size'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7594176544672244939</id><published>2011-10-04T11:29:00.001+08:00</published><updated>2011-10-04T11:30:56.762+08:00</updated><title type='text'>Oracle OpenWorld and JavaOne Announcements</title><content type='html'>The OTN Blog lists &lt;a href="http://blogs.oracle.com/otn/entry/the_most_exciting_oracle_openworld"&gt;The Most Exciting Oracle OpenWorld and JavaOne Announcements in One Place&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7594176544672244939?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7594176544672244939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7594176544672244939' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7594176544672244939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7594176544672244939'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/10/oracle-openworld-and-javaone.html' title='Oracle OpenWorld and JavaOne Announcements'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-1401851616913996616</id><published>2011-10-03T16:37:00.002+08:00</published><updated>2011-10-03T16:42:14.316+08:00</updated><title type='text'>RMAN Tips  --  3</title><content type='html'>ALWAYS mention the actual Start and End Times and Contents of all backups.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Whenever you&lt;/div&gt;&lt;div&gt;a. Post a query on forums / email lists&lt;/div&gt;&lt;div&gt;b. Talk to a colleague&lt;/div&gt;&lt;div&gt;c. Report to your manager&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;*always* mention the Start and End times and contents of your backups.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"Weekly Full Backup and Daily Incremental Backup" is empty of meaning when attempting to resolve a Backup-Restore issue.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;There are very noticeable differences between &lt;/div&gt;&lt;div&gt;a) "Backup of 11pm on Sunday"&lt;/div&gt;&lt;div&gt;and&lt;/div&gt;&lt;div&gt;b) "Database Backup that began at 11pm on Sunday and completed at 1am on Monday"&lt;/div&gt;&lt;div&gt;and&lt;/div&gt;&lt;div&gt;c) "'BACKUP DATABASE PLUS ARCHIVELOG' that began at 11pm on Sunday and completed at 9am on Monday"&lt;/div&gt;&lt;/div&gt;&lt;div&gt;and &lt;/div&gt;&lt;div&gt;d) "'BACKUP DATABASE INCREMENTAL LEVEL 0 PLUS ARCHIVELOG DELETE INPUT' that began at 11pm on Sunday and completed at 9am on Monday" &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Any DBA who thinks he's a DBA should know this and should understand why it is important to know the Start and End times and what was actually backed-up.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-1401851616913996616?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/1401851616913996616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=1401851616913996616' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1401851616913996616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1401851616913996616'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/10/rman-tips-3.html' title='RMAN Tips  --  3'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-166555150934842577</id><published>2011-09-30T00:32:00.004+08:00</published><updated>2011-09-30T00:39:17.682+08:00</updated><title type='text'>Another example of GATHER_TABLE_STATS and a Histogram</title><content type='html'>In response to a forum thread "&lt;a href="https://forums.oracle.com/forums/thread.jspa?threadID=2291134&amp;amp;tstart=0"&gt;Why not selecting index path .&lt;/a&gt;", I ran up this example :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select banner from v$version where rownum=1;&lt;br /&gt;&lt;br /&gt;BANNER&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; drop table test_index_count5 purge;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter system flush shared_pool;&lt;br /&gt;&lt;br /&gt;System altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter system flush shared_pool;&lt;br /&gt;&lt;br /&gt;System altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create table test_index_count5 (a number, b varchar2(15));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; insert into test_index_count5&lt;br /&gt;2  select 2, 'A String'&lt;br /&gt;3  from   dual&lt;br /&gt;4  connect by level &amp;lt;= 1000000;  1000000 rows created.  SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; insert into test_index_count5&lt;br /&gt;2  select 3, 'Another String'&lt;br /&gt;3  from   dual&lt;br /&gt;4  connect by level &amp;lt;= 2;  2 rows created.  SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; create index ind_a_tic5 on TEST_INDEX_COUNT5(a);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; exec dbms_stats.gather_table_stats(user,tabname=&amp;gt;'TEST_INDEX_COUNT5',estimate_percent=&amp;gt;100);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; set serverout off&lt;br /&gt;SQL&amp;gt; select /*+ gather_plan_statistics */ * from test_index_count5 where a=3;&lt;br /&gt;&lt;br /&gt;       A B&lt;br /&gt;---------- ---------------&lt;br /&gt;       3 Another String&lt;br /&gt;       3 Another String&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display_cursor('','','ALLSTATS LAST'));&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;--------------------------------------------------------------------------------------------------------------&lt;br /&gt;SQL_ID  2qu5fmh95yc4c, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ * from test_index_count5 where a=3&lt;br /&gt;&lt;br /&gt;Plan hash value: 1766596593&lt;br /&gt;&lt;br /&gt;-------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation         | Name              | Starts | E-Rows | A-Rows |   A-Time   | Buffers |&lt;br /&gt;-------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT  |                   |      1 |        |      2 |00:00:00.11 |    2393 |&lt;br /&gt;|*  1 |  TABLE ACCESS FULL| TEST_INDEX_COUNT5 |      1 |    500K|      2 |00:00:00.11 |    2393 |&lt;br /&gt;-------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt; 1 - filter("A"=3)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;18 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; set serverout on&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- execute the same query in different forms a few times&lt;br /&gt;SQL&amp;gt; select * from test_index_count5 where a=3;&lt;br /&gt;&lt;br /&gt;       A B&lt;br /&gt;---------- ---------------&lt;br /&gt;       3 Another String&lt;br /&gt;       3 Another String&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select     * FROM test_index_count5 where a=3;&lt;br /&gt;&lt;br /&gt;       A B&lt;br /&gt;---------- ---------------&lt;br /&gt;       3 Another String&lt;br /&gt;       3 Another String&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- execute dummy ddl to force a hard parse for subsequent queries&lt;br /&gt;SQL&amp;gt; comment on table TEST_INDEX_COUNT5 is 'TEST_INDEX_COUNT5';&lt;br /&gt;&lt;br /&gt;Comment created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; SELECT     * from test_index_count5 where a=3;&lt;br /&gt;&lt;br /&gt;       A B&lt;br /&gt;---------- ---------------&lt;br /&gt;       3 Another String&lt;br /&gt;       3 Another String&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from TEST_INDEX_COUNT5 where a=3;&lt;br /&gt;&lt;br /&gt;       A B&lt;br /&gt;---------- ---------------&lt;br /&gt;       3 Another String&lt;br /&gt;       3 Another String&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select     * from test_index_count5 WHERE a=3;&lt;br /&gt;&lt;br /&gt;       A B&lt;br /&gt;---------- ---------------&lt;br /&gt;       3 Another String&lt;br /&gt;       3 Another String&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- check col_usage&lt;br /&gt;SQL&amp;gt; select * from sys.col_usage$&lt;br /&gt;2  where obj# = (select object_id from user_objects where object_name = 'TEST_INDEX_COUNT5');&lt;br /&gt;&lt;br /&gt;no rows selected&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- Remember ! Col_usage is updated only on flush database monitoring&lt;br /&gt;SQL&amp;gt; -- normally this is done periodically by the background&lt;br /&gt;SQL&amp;gt; -- but we'll forcefully invoke it&lt;br /&gt;SQL&amp;gt; exec dbms_stats.flush_database_monitoring_info;&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select     * from test_index_count5 where a=3;&lt;br /&gt;&lt;br /&gt;       A B&lt;br /&gt;---------- ---------------&lt;br /&gt;       3 Another String&lt;br /&gt;       3 Another String&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from sys.col_usage$&lt;br /&gt;2  where obj# = (select object_id from user_objects where object_name = 'TEST_INDEX_COUNT5');&lt;br /&gt;&lt;br /&gt;    OBJ#    INTCOL# EQUALITY_PREDS EQUIJOIN_PREDS NONEQUIJOIN_PREDS RANGE_PREDS LIKE_PREDS NULL_PREDS&lt;br /&gt;---------- ---------- -------------- -------------- ----------------- ----------- ---------- ----------&lt;br /&gt;TIMESTAMP&lt;br /&gt;---------&lt;br /&gt;   85617          1              1              0                 0           0          0          0&lt;br /&gt;30-SEP-11&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- re gather_stats&lt;br /&gt;SQL&amp;gt; exec dbms_stats.gather_table_stats(user,tabname=&amp;gt;'TEST_INDEX_COUNT5',estimate_percent=&amp;gt;100);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- now execute the query&lt;br /&gt;SQL&amp;gt; set serveroutput off&lt;br /&gt;SQL&amp;gt; select /*+ gather_plan_statistics */ * from test_index_count5 where a=3;&lt;br /&gt;&lt;br /&gt;       A B&lt;br /&gt;---------- ---------------&lt;br /&gt;       3 Another String&lt;br /&gt;       3 Another String&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display_cursor('','','ALLSTATS LAST'));&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;--------------------------------------------------------------------------------------------------------------&lt;br /&gt;SQL_ID  2qu5fmh95yc4c, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ * from test_index_count5 where a=3&lt;br /&gt;&lt;br /&gt;Plan hash value: 4117659660&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                   | Name              | Starts | E-Rows | A-Rows |   A-Time   | Buffers |&lt;br /&gt;-----------------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT            |                   |      1 |        |      2 |00:00:00.01 |       6 |&lt;br /&gt;|   1 |  TABLE ACCESS BY INDEX ROWID| TEST_INDEX_COUNT5 |      1 |      2 |      2 |00:00:00.01 |       6 |&lt;br /&gt;|*  2 |   INDEX RANGE SCAN          | IND_A_TIC5        |      1 |      2 |      2 |00:00:00.01 |       4 |&lt;br /&gt;-----------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt; 2 - access("A"=3)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;19 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; set serveroutput on&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select * from user_tab_histograms where table_name = 'TEST_INDEX_COUNT5' and column_name = 'A';&lt;br /&gt;&lt;br /&gt;TABLE_NAME&lt;br /&gt;------------------------------&lt;br /&gt;COLUMN_NAME&lt;br /&gt;--------------------------------------------------------------------------------------------------------------&lt;br /&gt;ENDPOINT_NUMBER ENDPOINT_VALUE&lt;br /&gt;--------------- --------------&lt;br /&gt;ENDPOINT_ACTUAL_VALUE&lt;br /&gt;--------------------------------------------------------------------------------------------------------------&lt;br /&gt;TEST_INDEX_COUNT5&lt;br /&gt;A&lt;br /&gt;      1000000              2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TEST_INDEX_COUNT5&lt;br /&gt;A&lt;br /&gt;      1000002              3&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The test cases in that forum thread were differently using 100,000 rows and 1million rows.  As Tom Kyte observed in his response when the same test case was posted to him  (see the link in the forums thread)  : &lt;i&gt;&lt;a name="PAGETOP"&gt;In fact, you probably don't even need the method_opt,  just the running of the queries should be enough (but might not be in  this truly massively skewed example - we might not sample 2 at all - it  might not get picked up) &lt;/a&gt;.&lt;/i&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Whenever I ran the 1million row test case, Oracle didn't create the right histogram until I explicitly added ESTIMATE_PERCENT 100.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Remember that when you have very high data skew, sampling may not be able to identify the skew.  The greater the skew,  the larger should your sampling be to identify the skew.  &lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-166555150934842577?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/166555150934842577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=166555150934842577' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/166555150934842577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/166555150934842577'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/09/another-example-of-gathertablestats-and.html' title='Another example of GATHER_TABLE_STATS and a Histogram'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-1415208334999211658</id><published>2011-09-22T18:30:00.001+08:00</published><updated>2011-09-22T18:30:54.370+08:00</updated><title type='text'>Oracle Android App</title><content type='html'>Yesterday, I downloaded and installed the Oracle Android App onto my Samsung Galaxy S phone. &lt;br/&gt; I must say :  the App provides a quick overview of what's happening in the Oracle World. &lt;br/&gt; It is certainly much faster and better organised than the FaceBook App. &lt;br/&gt; It provides listings of news updates and a few blog posts. &lt;br/&gt;  &lt;br/&gt; . &lt;br/&gt; &lt;div style='clear: both; text-align: center; font-size: xx-small;'&gt;Published with Blogger-droid v1.7.4&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-1415208334999211658?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/1415208334999211658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=1415208334999211658' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1415208334999211658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1415208334999211658'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/09/oracle-android-app.html' title='Oracle Android App'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-5622350828789427527</id><published>2011-09-21T23:58:00.003+08:00</published><updated>2011-09-22T00:41:04.243+08:00</updated><title type='text'>An Index that is a "subset" of a pre-existing Index</title><content type='html'>It is a common [mis]understanding that creating a new Index that is a subset of an existing Index is an unnecessary overhead.  The argument goes "if you have an Index on (A,B,C) this Index can be used to satisfy queries where predicate 'A' is specified, so creating an additional Index on (A) alone is an unnecessary overhead".&lt;br /&gt;It is true that the the Index could be used, but the Cost Based Optimizer also computes a "COST" for using the Index.  A composite Index is larger (in terms of Leaf Blocks to navigate) then a single-column Index.  Similarly, at times, the composite Index becomes so large that many queries are executed as FullTableScans !&lt;br /&gt;&lt;br /&gt;This question arose in a &lt;a href="https://forums.oracle.com/forums/thread.jspa?threadID=2287353&amp;amp;tstart=45"&gt;forums discussion today on how a CREATE INDEX an be speeded up&lt;/a&gt;. The CREATion of a  Index on (A) can actually read the existing Index on (A,B,C) without having to do a FullTableScan.  Furthermore, the new Index on (A) can satisfy queries on the single predicate better than the existing Index.&lt;br /&gt;&lt;br /&gt;Here I demonstrate both cases :&lt;br /&gt;1.  A CREATE INDEX reading an existing Index and avoiding a FullTableScan&lt;br /&gt;2.  An Index that is a "subset" of an existing Index being useful&lt;br /&gt;&lt;br /&gt;I first setup the "demo" table&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; drop table objects_list purge;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- assume a "largeish" table -- the Remarks column makes the row length greater&lt;br /&gt;SQL&amp;gt; create table objects_list as&lt;br /&gt;2  select owner, object_name, subobject_name,  object_type, created, status,&lt;br /&gt;3  dbms_random.string('X',200) as Remarks&lt;br /&gt;4  from dba_objects&lt;br /&gt;5  /&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- in the absence of object_id, these columns constitute the Unique Index&lt;br /&gt;SQL&amp;gt; create unique index objects_list_u1 on objects_list (owner, object_name, subobject_name, object_type);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; exec dbms_stats.gather_table_stats('','OBJECTS_LIST',estimate_percent=&amp;gt;100,cascade=&amp;gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select blocks, num_rows from user_tables where table_name = 'OBJECTS_LIST';&lt;br /&gt;&lt;br /&gt;  BLOCKS   NUM_ROWS&lt;br /&gt;---------- ----------&lt;br /&gt;    2867      76955&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, I verify if I can use the composite Index to execute a query on the leading column alone :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; --- we should be able to use the Unique Index when querying for the leading column alone&lt;br /&gt;SQL&amp;gt; explain plan for&lt;br /&gt;2  select owner, count(*) from objects_list where owner like 'O%' group by owner order by owner;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 544682346&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation            | Name            | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT     |                 |     3 |    21 |    39   (0)| 00:00:01 |&lt;br /&gt;|   1 |  SORT GROUP BY NOSORT|                 |     3 |    21 |    39   (0)| 00:00:01 |&lt;br /&gt;|*  2 |   INDEX RANGE SCAN   | OBJECTS_LIST_U1 |  5141 | 35987 |    39   (0)| 00:00:01 |&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt; 2 - access("OWNER" LIKE 'O%')&lt;br /&gt;     filter("OWNER" LIKE 'O%')&lt;br /&gt;&lt;br /&gt;15 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select owner, count(*) from objects_list where owner like 'O%' group by owner order by owner;&lt;br /&gt;&lt;br /&gt;OWNER                            COUNT(*)&lt;br /&gt;------------------------------ ----------&lt;br /&gt;OBE                                    75&lt;br /&gt;OE                                     84&lt;br /&gt;OE1                                    55&lt;br /&gt;OLAPSYS                               719&lt;br /&gt;ORACLE_OCM                              8&lt;br /&gt;ORDDATA                               248&lt;br /&gt;ORDPLUGINS                             10&lt;br /&gt;ORDSYS                               2532&lt;br /&gt;OUTLN                                   9&lt;br /&gt;OWBSYS                                  2&lt;br /&gt;OWBSYS_AUDIT                           12&lt;br /&gt;&lt;br /&gt;11 rows selected.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Execution Plan&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;Plan hash value: 544682346&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation            | Name            | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT     |                 |     3 |    21 |    39   (0)| 00:00:01 |&lt;br /&gt;|   1 |  SORT GROUP BY NOSORT|                 |     3 |    21 |    39   (0)| 00:00:01 |&lt;br /&gt;|*  2 |   INDEX RANGE SCAN   | OBJECTS_LIST_U1 |  5141 | 35987 |    39   (0)| 00:00:01 |&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt; 2 - access("OWNER" LIKE 'O%')&lt;br /&gt;     filter("OWNER" LIKE 'O%')&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Statistics&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;        0  recursive calls&lt;br /&gt;        0  db block gets&lt;br /&gt;       30  consistent gets&lt;br /&gt;        0  physical reads&lt;br /&gt;        0  redo size&lt;br /&gt;      676  bytes sent via SQL*Net to client&lt;br /&gt;      419  bytes received via SQL*Net from client&lt;br /&gt;        2  SQL*Net roundtrips to/from client&lt;br /&gt;        0  sorts (memory)&lt;br /&gt;        0  sorts (disk)&lt;br /&gt;       11  rows processed&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Yes.  The composite Index is used even for the single column predicate "OWNER".  The query does 30 block gets.  (I've actually executed the query twice to eliminate recursive calls at the second execution).&lt;br /&gt;&lt;br /&gt;What if I created an Index on "OWNER" alone ?  It would be a "subset of the existing Index.&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; create index objects_list_n1 on objects_list (owner);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; --- now Oracle can use the leaner index for the same query&lt;br /&gt;SQL&amp;gt; --- check the "Cost"&lt;br /&gt;SQL&amp;gt; explain plan for&lt;br /&gt;2  select owner, count(*) from objects_list where owner like 'O%' group by owner order by owner;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 1721948621&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation            | Name            | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT     |                 |     3 |    21 |    14   (0)| 00:00:01 |&lt;br /&gt;|   1 |  SORT GROUP BY NOSORT|                 |     3 |    21 |    14   (0)| 00:00:01 |&lt;br /&gt;|*  2 |   INDEX RANGE SCAN   | OBJECTS_LIST_N1 |  5141 | 35987 |    14   (0)| 00:00:01 |&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt; 2 - access("OWNER" LIKE 'O%')&lt;br /&gt;     filter("OWNER" LIKE 'O%')&lt;br /&gt;&lt;br /&gt;15 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select owner, count(*) from objects_list where owner like 'O%' group by owner order by owner;&lt;br /&gt;&lt;br /&gt;OWNER                            COUNT(*)&lt;br /&gt;------------------------------ ----------&lt;br /&gt;OBE                                    75&lt;br /&gt;OE                                     84&lt;br /&gt;OE1                                    55&lt;br /&gt;OLAPSYS                               719&lt;br /&gt;ORACLE_OCM                              8&lt;br /&gt;ORDDATA                               248&lt;br /&gt;ORDPLUGINS                             10&lt;br /&gt;ORDSYS                               2532&lt;br /&gt;OUTLN                                   9&lt;br /&gt;OWBSYS                                  2&lt;br /&gt;OWBSYS_AUDIT                           12&lt;br /&gt;&lt;br /&gt;11 rows selected.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Execution Plan&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;Plan hash value: 1721948621&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation            | Name            | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT     |                 |     3 |    21 |    14   (0)| 00:00:01 |&lt;br /&gt;|   1 |  SORT GROUP BY NOSORT|                 |     3 |    21 |    14   (0)| 00:00:01 |&lt;br /&gt;|*  2 |   INDEX RANGE SCAN   | OBJECTS_LIST_N1 |  5141 | 35987 |    14   (0)| 00:00:01 |&lt;br /&gt;----------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt; 2 - access("OWNER" LIKE 'O%')&lt;br /&gt;     filter("OWNER" LIKE 'O%')&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Statistics&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;        0  recursive calls&lt;br /&gt;        0  db block gets&lt;br /&gt;       12  consistent gets&lt;br /&gt;        0  physical reads&lt;br /&gt;        0  redo size&lt;br /&gt;      676  bytes sent via SQL*Net to client&lt;br /&gt;      419  bytes received via SQL*Net from client&lt;br /&gt;        2  SQL*Net roundtrips to/from client&lt;br /&gt;        0  sorts (memory)&lt;br /&gt;        0  sorts (disk)&lt;br /&gt;       11  rows processed&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The new Index is used ! It has a lower "COST" (14 for the new Index versus 39 for the composite Index) and doing fewer block gets (12 versus 30).&lt;br /&gt;&lt;br /&gt;So, this new Index is better than the existing one for such queries.&lt;br /&gt;&lt;br /&gt;How was the Index created ?  I actually obtained a trace of the CREATE INDEX run.&lt;br /&gt;&lt;pre&gt;LOCK TABLE "OBJECTS_LIST" IN SHARE MODE  NOWAIT&lt;br /&gt;&lt;br /&gt;create index objects_list_n1 on objects_list (owner)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;call     count       cpu    elapsed       disk      query    current        rows&lt;br /&gt;------- ------  -------- ---------- ---------- ---------- ----------  ----------&lt;br /&gt;Parse        1      0.00       0.00          0          2          1           0&lt;br /&gt;Execute      1      0.27       0.29          1      77000        714           0&lt;br /&gt;Fetch        0      0.00       0.00          0          0          0           0&lt;br /&gt;------- ------  -------- ---------- ---------- ---------- ----------  ----------&lt;br /&gt;total        2      0.27       0.29          1      77002        715           0&lt;br /&gt;&lt;br /&gt;Misses in library cache during parse: 1&lt;br /&gt;Optimizer mode: ALL_ROWS&lt;br /&gt;Parsing user id: 187&lt;br /&gt;&lt;br /&gt;Rows     Row Source Operation&lt;br /&gt;-------  ---------------------------------------------------&lt;br /&gt;    1  INDEX BUILD NON UNIQUE OBJECTS_LIST_N1 (cr=77119 pr=1 pw=184 time=0 us)(object id 0)&lt;br /&gt;76955   SORT CREATE INDEX (cr=76965 pr=1 pw=0 time=857870 us)&lt;br /&gt;76955    INDEX FAST FULL SCAN OBJECTS_LIST_U1 (cr=76965 pr=1 pw=0 time=1649397 us)(object id 88291)&lt;br /&gt;&lt;pre&gt;Thus the CREATE INDEX OBJECTS_LIST_N1 actually did an Index Fast Full Scan of the existing Index OBJECTS_LIST_U1 !&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-5622350828789427527?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/5622350828789427527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=5622350828789427527' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5622350828789427527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5622350828789427527'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/09/index-that-is-subset-of-pre-existing.html' title='An Index that is a &quot;subset&quot; of a pre-existing Index'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-861916920525301186</id><published>2011-09-20T23:20:00.003+08:00</published><updated>2011-09-20T23:54:45.342+08:00</updated><title type='text'>RMAN Tips  --  2</title><content type='html'>Incremental Backup from a particular SCN&lt;br /&gt;&lt;br /&gt;RMAN allows you to take an Incremental Backup "FROM SCN".  Why ?  For the purpose of updating a Standby Database. &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;[oracle@localhost ~]$ sqlplus '/ as sysdba'&lt;br /&gt;&lt;br /&gt;SQL*Plus: Release 11.2.0.1.0 Production on Tue Sep 20 23:35:38 2011&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle.  All rights reserved.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Connected to:&lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production&lt;br /&gt;With the Partitioning, OLAP, Data Mining and Real Application Testing options&lt;br /&gt;&lt;br /&gt;SQL&gt; select current_scn from v$database;&lt;br /&gt;&lt;br /&gt;CURRENT_SCN&lt;br /&gt;-----------&lt;br /&gt;    9250081&lt;br /&gt;&lt;br /&gt;SQL&gt; exit&lt;br /&gt;Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production&lt;br /&gt;With the Partitioning, OLAP, Data Mining and Real Application Testing options&lt;br /&gt;[oracle@localhost ~]$ &lt;br /&gt;[oracle@localhost ~]$ rman target /&lt;br /&gt;&lt;br /&gt;Recovery Manager: Release 11.2.0.1.0 - Production on Tue Sep 20 23:36:07 2011&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.&lt;br /&gt;&lt;br /&gt;connected to target database: ORCL (DBID=1229390655)&lt;br /&gt;&lt;br /&gt;RMAN&gt; backup as compressed backupset incremental from SCN=9250021 database format '/addtl/oracle/tmp/%U';&lt;br /&gt;&lt;br /&gt;Starting backup at 20-SEP-11&lt;br /&gt;&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=27 device type=DISK&lt;br /&gt;allocated channel: ORA_DISK_2&lt;br /&gt;channel ORA_DISK_2: SID=34 device type=DISK&lt;br /&gt;backup will be obsolete on date 27-SEP-11&lt;br /&gt;archived logs will not be kept or backed up&lt;br /&gt;RMAN-06755: WARNING: datafile 1: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 2: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 3: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 4: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 5: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 6: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 7: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 8: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 9: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 10: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 11: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 12: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 13: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 15: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 16: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 17: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;RMAN-06755: WARNING: datafile 18: incremental-start SCN is too recent; using checkpoint SCN 9249229 instead&lt;br /&gt;channel ORA_DISK_1: starting compressed full datafile backup set&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) in backup set&lt;br /&gt;input datafile file number=00003 name=/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf&lt;br /&gt;input datafile file number=00016 name=/addtl/oracle/oradata/orcl/Uniform_64KB.dbf&lt;br /&gt;input datafile file number=00018 name=/addtl/oracle/oradata/orcl/MSSM.dbf&lt;br /&gt;input datafile file number=00015 name=/addtl/oracle/oradata/orcl/UNDO.dbf&lt;br /&gt;input datafile file number=00017 name=/usr/tmp/X.dbf&lt;br /&gt;input datafile file number=00002 name=/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf&lt;br /&gt;input datafile file number=00001 name=/home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;input datafile file number=00004 name=/home/oracle/app/oracle/oradata/orcl/users01.dbf&lt;br /&gt;input datafile file number=00014 name=/home/oracle/app/oracle/oradata/orcl/hemant_01.dbf&lt;br /&gt;channel ORA_DISK_1: starting piece 1 at 20-SEP-11&lt;br /&gt;channel ORA_DISK_2: starting compressed full datafile backup set&lt;br /&gt;channel ORA_DISK_2: specifying datafile(s) in backup set&lt;br /&gt;input datafile file number=00005 name=/home/oracle/app/oracle/oradata/orcl/example01.dbf&lt;br /&gt;input datafile file number=00006 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1046101119510758.dbf&lt;br /&gt;input datafile file number=00007 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1146416395631714.dbf&lt;br /&gt;input datafile file number=00008 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1170420963682633.dbf&lt;br /&gt;input datafile file number=00009 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1194425963955800.dbf&lt;br /&gt;input datafile file number=00010 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1218408858999342.dbf&lt;br /&gt;input datafile file number=00011 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1242310449730067.dbf&lt;br /&gt;input datafile file number=00012 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1266412439758696.dbf&lt;br /&gt;input datafile file number=00013 name=/home/oracle/app/oracle/oradata/orcl/APEX_1295922881855015.dbf&lt;br /&gt;channel ORA_DISK_2: starting piece 1 at 20-SEP-11&lt;br /&gt;channel ORA_DISK_2: finished piece 1 at 20-SEP-11&lt;br /&gt;piece handle=/addtl/oracle/tmp/52mn2bl3_1_1 tag=TAG20110920T233703 comment=NONE&lt;br /&gt;channel ORA_DISK_2: backup set complete, elapsed time: 00:00:35&lt;br /&gt;channel ORA_DISK_1: finished piece 1 at 20-SEP-11&lt;br /&gt;piece handle=/addtl/oracle/tmp/51mn2bl2_1_1 tag=TAG20110920T233703 comment=NONE&lt;br /&gt;channel ORA_DISK_1: backup set complete, elapsed time: 00:02:16&lt;br /&gt;&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;using channel ORA_DISK_2&lt;br /&gt;backup will be obsolete on date 27-SEP-11&lt;br /&gt;archived logs will not be kept or backed up&lt;br /&gt;channel ORA_DISK_1: starting compressed full datafile backup set&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) in backup set&lt;br /&gt;including current control file in backup set&lt;br /&gt;channel ORA_DISK_1: starting piece 1 at 20-SEP-11&lt;br /&gt;channel ORA_DISK_1: finished piece 1 at 20-SEP-11&lt;br /&gt;piece handle=/addtl/oracle/tmp/53mn2bpb_1_1 tag=TAG20110920T233703 comment=NONE&lt;br /&gt;channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01&lt;br /&gt;Finished backup at 20-SEP-11&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;RMAN "automatically" determines an appropriate SCN.&lt;br /&gt;&lt;br /&gt;Is this database backup usable for any other purpose ?&lt;br /&gt;Is it "visible" ?&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;[oracle@localhost ~]$ rman target /&lt;br /&gt;&lt;br /&gt;Recovery Manager: Release 11.2.0.1.0 - Production on Tue Sep 20 23:41:06 2011&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.&lt;br /&gt;&lt;br /&gt;connected to target database: ORCL (DBID=1229390655)&lt;br /&gt;&lt;br /&gt;RMAN&gt; list backup summary;&lt;br /&gt;&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;&lt;br /&gt;List of Backups&lt;br /&gt;===============&lt;br /&gt;Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag&lt;br /&gt;------- -- -- - ----------- --------------- ------- ------- ---------- ---&lt;br /&gt;130     B  F  A DISK        31-MAY-11       1       1       YES        TAG20110531T224447&lt;br /&gt;132     B  A  A DISK        31-MAY-11       1       1       YES        TAG20110531T224945&lt;br /&gt;133     B  F  A DISK        31-MAY-11       1       1       NO         TAG20110531T224947&lt;br /&gt;134     B  F  A DISK        05-JUL-11       1       1       YES        TAG20110705T230230&lt;br /&gt;135     B  F  A DISK        05-JUL-11       1       1       YES        TAG20110705T230230&lt;br /&gt;136     B  F  A DISK        05-JUL-11       1       1       NO         TAG20110705T230640&lt;br /&gt;137     B  F  A DISK        13-JUL-11       1       1       NO         TAG20110713T224918&lt;br /&gt;138     B  F  A DISK        03-SEP-11       1       1       NO         TAG20110903T232648&lt;br /&gt;139     B  F  A DISK        03-SEP-11       1       1       YES        TAG20110903T234602&lt;br /&gt;140     B  F  A DISK        03-SEP-11       1       1       YES        TAG20110903T234602&lt;br /&gt;141     B  F  A DISK        03-SEP-11       1       1       NO         TAG20110903T235631&lt;br /&gt;142     B  A  A DISK        04-SEP-11       1       1       YES        TAG20110904T001454&lt;br /&gt;143     B  A  A DISK        04-SEP-11       1       1       YES        TAG20110904T001454&lt;br /&gt;144     B  F  A DISK        04-SEP-11       1       1       NO         TAG20110904T001459&lt;br /&gt;145     B  A  A DISK        16-SEP-11       1       2       NO         TAG20110916T225318&lt;br /&gt;146     B  A  A DISK        16-SEP-11       1       2       NO         TAG20110916T225318&lt;br /&gt;147     B  F  A DISK        16-SEP-11       1       1       NO         TAG20110916T225321&lt;br /&gt;148     B     A DISK        20-SEP-11       1       1       YES        TAG20110920T233703&lt;br /&gt;149     B     A DISK        20-SEP-11       1       1       YES        TAG20110920T233703&lt;br /&gt;150     B     A DISK        20-SEP-11       1       1       YES        TAG20110920T233703&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note the last 3 entries.  The Backup Level (column "LV") is not updated.  There is no controlfile autobackup !&lt;br /&gt;Note the warning towards the end of the backup run : "archived logs will not be kept or backed up" !  I must explicitly backup the archivelogs that I need for the Standby. &lt;br /&gt;(The BACKUP FROM INCREMENTAL SCN cannot include a "PLUS ARCHIVELOG")&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;[oracle@localhost ~]$ cd /addtl/oracle/tmp&lt;br /&gt;[oracle@localhost tmp]$ ls -ltr&lt;br /&gt;total 2596&lt;br /&gt;-rw-rw---- 1 oracle oracle  106496 Sep 20 23:37 52mn2bl3_1_1&lt;br /&gt;-rw-rw---- 1 oracle oracle 1343488 Sep 20 23:39 51mn2bl2_1_1&lt;br /&gt;-rw-rw---- 1 oracle oracle 1196032 Sep 20 23:39 53mn2bpb_1_1&lt;br /&gt;[oracle@localhost tmp]$ &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;However, I can list a datafile individually, thus "seeing" the backup done today :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;RMAN&gt; list backup of datafile 1;&lt;br /&gt;&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;&lt;br /&gt;List of Backup Sets&lt;br /&gt;===================&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;BS Key  Type LV Size       Device Type Elapsed Time Completion Time&lt;br /&gt;------- ---- -- ---------- ----------- ------------ ---------------&lt;br /&gt;135     Full    659.84M    DISK        00:04:08     05-JUL-11      &lt;br /&gt;        BP Key: 135   Status: AVAILABLE  Compressed: YES  Tag: TAG20110705T230230&lt;br /&gt;        Piece Name: /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_07_05/o1_mf_nnndf_TAG20110705T230230_7169w8s7_.bkp&lt;br /&gt;  List of Datafiles in backup set 135&lt;br /&gt;  File LV Type Ckp SCN    Ckp Time  Name&lt;br /&gt;  ---- -- ---- ---------- --------- ----&lt;br /&gt;  1       Full 8286449    05-JUL-11 /home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;&lt;br /&gt;BS Key  Type LV Size       Device Type Elapsed Time Completion Time&lt;br /&gt;------- ---- -- ---------- ----------- ------------ ---------------&lt;br /&gt;140     Full    2.81G      DISK        00:10:28     03-SEP-11      &lt;br /&gt;        BP Key: 140   Status: AVAILABLE  Compressed: YES  Tag: TAG20110903T234602&lt;br /&gt;        Piece Name: /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_03/o1_mf_nnndf_TAG20110903T234602_764lxvd6_.bkp&lt;br /&gt;  List of Datafiles in backup set 140&lt;br /&gt;  File LV Type Ckp SCN    Ckp Time  Name&lt;br /&gt;  ---- -- ---- ---------- --------- ----&lt;br /&gt;  1       Full 9008606    03-SEP-11 /home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;&lt;br /&gt;BS Key  Type LV Size       Device Type Elapsed Time Completion Time&lt;br /&gt;------- ---- -- ---------- ----------- ------------ ---------------&lt;br /&gt;149     Incr    1.27M      DISK        00:02:13     20-SEP-11      &lt;br /&gt;        BP Key: 151   Status: AVAILABLE  Compressed: YES  Tag: TAG20110920T233703&lt;br /&gt;        Piece Name: /addtl/oracle/tmp/51mn2bl2_1_1&lt;br /&gt;        Keep: NOLOGS             Until: 27-SEP-11      &lt;br /&gt;  List of Datafiles in backup set 149&lt;br /&gt;  File LV Type Ckp SCN    Ckp Time  Name&lt;br /&gt;  ---- -- ---- ---------- --------- ----&lt;br /&gt;  1       Incr 9250390    20-SEP-11 /home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There are 3 different SCNs now. The one I specified in the INCREMENTAL FROM SCN. The one that RMAN "automatically" used.  And the SCN tht appears as the Checkpoint SCN in the LIST BACKUP.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-861916920525301186?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/861916920525301186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=861916920525301186' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/861916920525301186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/861916920525301186'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/09/rman-tips-2.html' title='RMAN Tips  --  2'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-5329633250487165094</id><published>2011-09-17T22:39:00.002+08:00</published><updated>2011-09-17T22:41:44.394+08:00</updated><title type='text'>Very successful Golden Gate workshop at SG RACSIG</title><content type='html'>Jigar led the Singapore RACSIG Golden Gate workshop very well today.  It was quite apparent that he knows the product well and is enthusiastic about sharing his knowledge.&lt;br /&gt;Ravi also added a few observations and asked "review questions" of the members present.&lt;br /&gt;&lt;br /&gt;Thank you very much Jigar.&lt;br /&gt;Thank you Ravi.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-5329633250487165094?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/5329633250487165094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=5329633250487165094' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5329633250487165094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5329633250487165094'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/09/very-successful-golden-gate-workshop-at.html' title='Very successful Golden Gate workshop at SG RACSIG'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-5951548843741068862</id><published>2011-09-16T22:52:00.002+08:00</published><updated>2011-09-16T23:12:37.826+08:00</updated><title type='text'>RMAN Tips  --  1</title><content type='html'>Restoring ArchiveLogs to an alternate location &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;RMAN&gt; list archivelog all;&lt;br /&gt;&lt;br /&gt;specification does not match any archived log in the repository&lt;br /&gt;&lt;br /&gt;RMAN&gt; sql 'alter system switch logfile';&lt;br /&gt;&lt;br /&gt;sql statement: alter system switch logfile&lt;br /&gt;&lt;br /&gt;RMAN&gt; list archivelog all;&lt;br /&gt;&lt;br /&gt;List of Archived Log Copies for database with db_unique_name ORCL&lt;br /&gt;=====================================================================&lt;br /&gt;&lt;br /&gt;Key     Thrd Seq     S Low Time &lt;br /&gt;------- ---- ------- - ---------&lt;br /&gt;806     1    237     A 11-SEP-11&lt;br /&gt;        Name: /addtl/oracle/flash_recovery_area/ORCL/archivelog/2011_09_16/o1_mf_1_237_776rnnow_.arc&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;RMAN&gt; backup archivelog all;&lt;br /&gt;&lt;br /&gt;Starting backup at 16-SEP-11&lt;br /&gt;current log archived&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;using channel ORA_DISK_2&lt;br /&gt;channel ORA_DISK_1: starting archived log backup set&lt;br /&gt;channel ORA_DISK_1: specifying archived log(s) in backup set&lt;br /&gt;input archived log thread=1 sequence=237 RECID=806 STAMP=762043927&lt;br /&gt;channel ORA_DISK_1: starting piece 1 at 16-SEP-11&lt;br /&gt;channel ORA_DISK_2: starting archived log backup set&lt;br /&gt;channel ORA_DISK_2: specifying archived log(s) in backup set&lt;br /&gt;input archived log thread=1 sequence=238 RECID=807 STAMP=762043998&lt;br /&gt;channel ORA_DISK_2: starting piece 1 at 16-SEP-11&lt;br /&gt;channel ORA_DISK_1: finished piece 1 at 16-SEP-11&lt;br /&gt;piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp tag=TAG20110916T225318 comment=NONE&lt;br /&gt;channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01&lt;br /&gt;channel ORA_DISK_2: finished piece 1 at 16-SEP-11&lt;br /&gt;piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp tag=TAG20110916T225318 comment=NONE&lt;br /&gt;channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02&lt;br /&gt;Finished backup at 16-SEP-11&lt;br /&gt;&lt;br /&gt;Starting Control File and SPFILE Autobackup at 16-SEP-11&lt;br /&gt;piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_09_16/o1_mf_s_762044001_776rq1r5_.bkp comment=NONE&lt;br /&gt;Finished Control File and SPFILE Autobackup at 16-SEP-11&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, I have two ArchiveLogs (SEQUENCE# 237 and 238) backed up to two BackupSets in /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/&lt;br /&gt;&lt;br /&gt;I now delete the two ArchiveLogs :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;RMAN&gt; exit&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Recovery Manager complete.&lt;br /&gt;[oracle@localhost ~]$ cd /addtl/oracle/flash_recovery_area/ORCL/archivelog/2011_09_16/&lt;br /&gt;[oracle@localhost 2011_09_16]$ ls -l&lt;br /&gt;total 21604&lt;br /&gt;-rw-rw---- 1 oracle oracle 22071296 Sep 16 22:52 o1_mf_1_237_776rnnow_.arc&lt;br /&gt;-rw-rw---- 1 oracle oracle    17920 Sep 16 22:53 o1_mf_1_238_776rpyof_.arc&lt;br /&gt;[oracle@localhost 2011_09_16]$ &lt;br /&gt;[oracle@localhost 2011_09_16]$ rm *.arc&lt;br /&gt;[oracle@localhost 2011_09_16]$ ls -l&lt;br /&gt;total 0&lt;br /&gt;[oracle@localhost 2011_09_16]$ &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If I were to restore the ArchiveLogs to an alternate / test server, where I have copied the BackpSets to /tmp and want to restore the ArchiveLogs to /tmp as well, I must first begin with CATALOGing the BackupSets :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;[oracle@localhost2 2011_09_16]$ ls -l /tmp/*bkp&lt;br /&gt;-rw-rw---- 1 oracle oracle 22072832 Sep 16 22:57 /tmp/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp&lt;br /&gt;-rw-rw---- 1 oracle oracle    19456 Sep 16 22:57 /tmp/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp&lt;br /&gt;[oracle@localhost2 2011_09_16]$ &lt;br /&gt;[oracle@localhost2 2011_09_16]$ rman target /&lt;br /&gt;&lt;br /&gt;Recovery Manager: Release 11.2.0.1.0 - Production on Fri Sep 16 22:58:59 2011&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.&lt;br /&gt;&lt;br /&gt;connected to target database: ORCL (DBID=1229390655)&lt;br /&gt;&lt;br /&gt;RMAN&gt; catalog start with '/tmp/';&lt;br /&gt;&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;searching for all files that match the pattern /tmp/&lt;br /&gt;&lt;br /&gt;List of Files Unknown to the Database&lt;br /&gt;=====================================&lt;br /&gt;File Name: /tmp/hsperfdata_oracle/2469&lt;br /&gt;File Name: /tmp/.X0-lock&lt;br /&gt;File Name: /tmp/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp&lt;br /&gt;File Name: /tmp/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp&lt;br /&gt;&lt;br /&gt;Do you really want to catalog the above files (enter YES or NO)? YES&lt;br /&gt;cataloging files...&lt;br /&gt;cataloging done&lt;br /&gt;&lt;br /&gt;List of Cataloged Files&lt;br /&gt;=======================&lt;br /&gt;File Name: /tmp/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp&lt;br /&gt;File Name: /tmp/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp&lt;br /&gt;&lt;br /&gt;List of Files Which Where Not Cataloged&lt;br /&gt;=======================================&lt;br /&gt;File Name: /tmp/hsperfdata_oracle/2469&lt;br /&gt;  RMAN-07517: Reason: The file header is corrupted&lt;br /&gt;File Name: /tmp/.X0-lock&lt;br /&gt;  RMAN-07517: Reason: The file header is corrupted&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I can now restore the ArchiveLogs to /tmp  (Note : The SET ARCHIVELOG DESTINATION command must be in a Run Block.  It cannot be an independent command like a SET UNTIL) :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;RMAN&gt; list archivelog all;&lt;br /&gt;&lt;br /&gt;specification does not match any archived log in the repository&lt;br /&gt;&lt;br /&gt;RMAN&gt; run&lt;br /&gt;2&gt; {&lt;br /&gt;3&gt; set ARCHIVELOG DESTINATION TO '/tmp';&lt;br /&gt;4&gt; restore archivelog sequence between 237 and 238;&lt;br /&gt;5&gt; }&lt;br /&gt;&lt;br /&gt;executing command: SET ARCHIVELOG DESTINATION&lt;br /&gt;&lt;br /&gt;Starting restore at 16-SEP-11&lt;br /&gt;using channel ORA_DISK_1&lt;br /&gt;using channel ORA_DISK_2&lt;br /&gt;&lt;br /&gt;channel ORA_DISK_1: starting archived log restore to user-specified destination&lt;br /&gt;archived log destination=/tmp&lt;br /&gt;channel ORA_DISK_1: restoring archived log&lt;br /&gt;archived log thread=1 sequence=237&lt;br /&gt;channel ORA_DISK_1: reading from backup piece /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp&lt;br /&gt;channel ORA_DISK_2: starting archived log restore to user-specified destination&lt;br /&gt;archived log destination=/tmp&lt;br /&gt;channel ORA_DISK_2: restoring archived log&lt;br /&gt;archived log thread=1 sequence=238&lt;br /&gt;channel ORA_DISK_2: reading from backup piece /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp&lt;br /&gt;channel ORA_DISK_2: piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp tag=TAG20110916T225318&lt;br /&gt;channel ORA_DISK_2: restored backup piece 1&lt;br /&gt;channel ORA_DISK_2: restore complete, elapsed time: 00:00:01&lt;br /&gt;channel ORA_DISK_1: piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp tag=TAG20110916T225318&lt;br /&gt;channel ORA_DISK_1: restored backup piece 1&lt;br /&gt;channel ORA_DISK_1: restore complete, elapsed time: 00:00:03&lt;br /&gt;Finished restore at 16-SEP-11&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;RMAN&gt; list archivelog all;&lt;br /&gt;&lt;br /&gt;List of Archived Log Copies for database with db_unique_name ORCL&lt;br /&gt;=====================================================================&lt;br /&gt;&lt;br /&gt;Key     Thrd Seq     S Low Time &lt;br /&gt;------- ---- ------- - ---------&lt;br /&gt;811     1    237     A 11-SEP-11&lt;br /&gt;        Name: /tmp/1_237_749171050.dbf&lt;br /&gt;&lt;br /&gt;810     1    238     A 16-SEP-11&lt;br /&gt;        Name: /tmp/1_238_749171050.dbf&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Why would I want to / need to restore ArchiveLogs to another location ?&lt;br /&gt;a.  On the alternate / test server I do not have the same mount point point for ArchiveLogs as the primary.&lt;br /&gt;b.  On the alternate / test server, the mount point is much smaller but I do have another mount point that has enough space to restore ArchiveLogs to.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : What other way(s) can be used to restore ArchiveLogs to another location ?&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-5951548843741068862?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/5951548843741068862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=5951548843741068862' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5951548843741068862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5951548843741068862'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/09/rman-tips-1.html' title='RMAN Tips  --  1'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-3797241081856554508</id><published>2011-09-11T00:17:00.002+08:00</published><updated>2011-09-11T00:22:33.861+08:00</updated><title type='text'>Outer Join Queries</title><content type='html'>Outer Join queries are difficult to understand initially.  Effectively, an Outer Join query allows the developer to create dummy rows (with NULLs for the returned columns) for a table when a join to another table would fail.  Thus, the developer can see rows in the other table for which there are no corresponding entries in the "join failed" table.&lt;br /&gt;&lt;br /&gt;A simple example (from the classic SCOTT schema) is a DEPTNO 40 which has been created in the DEPT table but for which no employees exist in the EMP table.  Thus a join between DEPT and EMP on DEPTNO would, normally, never return the row for DEPTNO=40 from the DEPT table because the join fails.  An OuterJoin definition against EMP allows this row to be retrieved from DEPT with a "dummy" row (and NULL values) from the EMP table.&lt;br /&gt;&lt;br /&gt;In how many ways can Outer Joins be achieved ?  Here I present an alternative that does not have to use the Outer Join (+) syntax :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&gt; select deptno from dept;&lt;br /&gt;&lt;br /&gt;    DEPTNO&lt;br /&gt;----------&lt;br /&gt;        10&lt;br /&gt;        20&lt;br /&gt;        30&lt;br /&gt;        40&lt;br /&gt;&lt;br /&gt;SQL&gt; select deptno, count(*) from emp group by deptno order by deptno;&lt;br /&gt;&lt;br /&gt;    DEPTNO   COUNT(*)&lt;br /&gt;---------- ----------&lt;br /&gt;        10          3&lt;br /&gt;        20          5&lt;br /&gt;        30          6&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- dept 40 exists in dept but no employees present in emp&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; REM Other ways to write Outer Joins&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- most common way&lt;br /&gt;SQL&gt; select d.deptno, nvl(e.ename,'No employee')&lt;br /&gt;  2  from dept d, emp e&lt;br /&gt;  3  where d.deptno=e.deptno(+)&lt;br /&gt;  4  order by deptno&lt;br /&gt;  5  /&lt;br /&gt;&lt;br /&gt;    DEPTNO NVL(E.ENAME&lt;br /&gt;---------- -----------&lt;br /&gt;        10 CLARK&lt;br /&gt;        10 KING&lt;br /&gt;        10 MILLER&lt;br /&gt;        20 JONES&lt;br /&gt;        20 FORD&lt;br /&gt;        20 ADAMS&lt;br /&gt;        20 SMITH&lt;br /&gt;        20 SCOTT&lt;br /&gt;        30 WARD&lt;br /&gt;        30 TURNER&lt;br /&gt;        30 ALLEN&lt;br /&gt;        30 JAMES&lt;br /&gt;        30 BLAKE&lt;br /&gt;        30 MARTIN&lt;br /&gt;        40 No employee&lt;br /&gt;&lt;br /&gt;15 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- another way&lt;br /&gt;SQL&gt; select d.deptno, e.ename&lt;br /&gt;  2  from dept d, emp e&lt;br /&gt;  3  where d.deptno=e.deptno&lt;br /&gt;  4  union all&lt;br /&gt;  5  select d.deptno,'No employee'&lt;br /&gt;  6  from dept d&lt;br /&gt;  7  where deptno not in (select distinct e.deptno from emp e)&lt;br /&gt;  8  order by deptno&lt;br /&gt;  9  /&lt;br /&gt;&lt;br /&gt;    DEPTNO ENAME&lt;br /&gt;---------- -----------&lt;br /&gt;        10 CLARK&lt;br /&gt;        10 MILLER&lt;br /&gt;        10 KING&lt;br /&gt;        20 JONES&lt;br /&gt;        20 SMITH&lt;br /&gt;        20 SCOTT&lt;br /&gt;        20 FORD&lt;br /&gt;        20 ADAMS&lt;br /&gt;        30 WARD&lt;br /&gt;        30 TURNER&lt;br /&gt;        30 ALLEN&lt;br /&gt;        30 JAMES&lt;br /&gt;        30 MARTIN&lt;br /&gt;        30 BLAKE&lt;br /&gt;        40 No employee&lt;br /&gt;&lt;br /&gt;15 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;How would you write this query using ANSI syntax ?  Are there any other ways to fetch the result set ?&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-3797241081856554508?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/3797241081856554508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=3797241081856554508' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3797241081856554508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3797241081856554508'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/09/outer-join-queries.html' title='Outer Join Queries'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4254064611492864848</id><published>2011-09-04T16:34:00.002+08:00</published><updated>2011-09-04T16:37:52.080+08:00</updated><title type='text'>Splitting a Range Partitioned Table</title><content type='html'>Here's a simple demonstration of splitting a Range Partitioned Table :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&gt; --- Create a Table with a MAXVALUE partition&lt;br /&gt;SQL&gt; drop table sales purge;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&gt; create table sales&lt;br /&gt;  2  (order_id    number not null,&lt;br /&gt;  3   sale_date   date,&lt;br /&gt;  4   cust_id     number,&lt;br /&gt;  5   prod_id     number,&lt;br /&gt;  6   remarks     varchar2(128))&lt;br /&gt;  7  partition by range (sale_date)&lt;br /&gt;  8  (partition P_2007 values less than (to_date('01-JAN-2008')),&lt;br /&gt;  9  partition P_2008 values less than (to_date('01-JAN-2009')),&lt;br /&gt; 10  partition P_2009 values less than (to_date('01-JAN-2010')),&lt;br /&gt; 11  partition P_2010 values less than (to_date('01-JAN-2011')),&lt;br /&gt; 12  partition P_MAX  values less than (MAXVALUE)&lt;br /&gt; 13  )&lt;br /&gt; 14  /&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- insert sales for years 2007 to 2011&lt;br /&gt;SQL&gt; insert into sales values (1,to_date('15-JAN-2007','DD-MON-YYYY'),1,1,'First Sale in 2007');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into sales values (2,to_date('15-JUL-2008','DD-MON-YYYY'),1,2,'Sale in 2008');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into sales values (3,to_date('15-JUL-2009','DD-MON-YYYY'),1,3,'Sale in 2009');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into sales values (4,to_date('15-JUL-2010','DD-MON-YYYY'),1,2,'Sale in 2010');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into sales values (5,to_date('15-AUG-2010','DD-MON-YYYY'),2,3,'Cust_2 in 2010');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into sales values (6,to_date('01-FEB-2011','DD-MON-YYYY'),1,2,'Feb 2011');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into sales values (7,to_date('01-MAR-2011','DD-MON-YYYY'),2,3,'Mar 2011');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into sales values (8,to_date('01-APR-2011','DD-MON-YYYY'),2,3,'Apr 2011');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into sales values (9,to_date('01-MAY-2011','DD-MON-YYYY'),3,3,'Cust_3 !');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- create a global index and a local index&lt;br /&gt;SQL&gt; create unique index S_ORDER_ID_NDX on SALES (ORDER_ID);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&gt; create index S_SALE_DT_NDX on SALES (SALE_DATE) LOCAL ;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- gather stats&lt;br /&gt;SQL&gt; exec dbms_stats.gather_table_stats('','SALES',estimate_percent=&gt;100,granularity=&gt;'ALL');&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&gt; select partition_name, num_rows&lt;br /&gt;  2  from user_tab_partitions&lt;br /&gt;  3  where table_name = 'SALES'&lt;br /&gt;  4  order by partition_position&lt;br /&gt;  5  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                   NUM_ROWS&lt;br /&gt;------------------------------ ----------&lt;br /&gt;P_2007                                  1&lt;br /&gt;P_2008                                  1&lt;br /&gt;P_2009                                  1&lt;br /&gt;P_2010                                  2&lt;br /&gt;P_MAX                                   4&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- We now find that year 2011 sales went into the Max value partition !&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- split Max value partition&lt;br /&gt;SQL&gt; alter table sales&lt;br /&gt;  2  split partition P_MAX&lt;br /&gt;  3  at (to_date('01-JAN-2012','DD-MON-YYYY'))&lt;br /&gt;  4  into (partition P_2011,partition P_MAX)&lt;br /&gt;  5  update global indexes&lt;br /&gt;  6  /&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table sales&lt;br /&gt;  2  split partition P_MAX&lt;br /&gt;  3  at (to_date('01-JAN-2013','DD-MON-YYYY'))&lt;br /&gt;  4  into (partition P_2012,partition P_MAX)&lt;br /&gt;  5  update global indexes&lt;br /&gt;  6  /&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table sales&lt;br /&gt;  2  split partition P_MAX&lt;br /&gt;  3  at (to_date('01-JAN-2014','DD-MON-YYYY'))&lt;br /&gt;  4  into (partition P_2013,partition P_MAX)&lt;br /&gt;  5  update global indexes&lt;br /&gt;  6  /&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- check the indexes&lt;br /&gt;SQL&gt; select status from user_indexes where index_name = 'S_ORDER_ID_NDX';&lt;br /&gt;&lt;br /&gt;STATUS&lt;br /&gt;--------&lt;br /&gt;VALID&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; select partition_name, status&lt;br /&gt;  2  from user_ind_partitions&lt;br /&gt;  3  where index_name = 'S_SALE_DT_NDX'&lt;br /&gt;  4  order by partition_position&lt;br /&gt;  5  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 STATUS&lt;br /&gt;------------------------------ --------&lt;br /&gt;P_2007                         USABLE&lt;br /&gt;P_2008                         USABLE&lt;br /&gt;P_2009                         USABLE&lt;br /&gt;P_2010                         USABLE&lt;br /&gt;P_2011                         USABLE&lt;br /&gt;P_2012                         USABLE&lt;br /&gt;P_2013                         USABLE&lt;br /&gt;P_MAX                          USABLE&lt;br /&gt;&lt;br /&gt;8 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- The LOCAL index (equi-partitioned) is automatically maintained&lt;br /&gt;SQL&gt; -- with even new partitions created&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- gather stats&lt;br /&gt;SQL&gt; exec dbms_stats.gather_table_stats('','SALES',estimate_percent=&gt;100,granularity=&gt;'ALL');&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&gt; select partition_name, num_rows&lt;br /&gt;  2  from user_tab_partitions&lt;br /&gt;  3  where table_name = 'SALES'&lt;br /&gt;  4  order by partition_position&lt;br /&gt;  5  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                   NUM_ROWS&lt;br /&gt;------------------------------ ----------&lt;br /&gt;P_2007                                  1&lt;br /&gt;P_2008                                  1&lt;br /&gt;P_2009                                  1&lt;br /&gt;P_2010                                  2&lt;br /&gt;P_2011                                  4&lt;br /&gt;P_2012                                  0&lt;br /&gt;P_2013                                  0&lt;br /&gt;P_MAX                                   0&lt;br /&gt;&lt;br /&gt;8 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The time to execute the SPLIT commands depends on the number of rows present in the P_MAX partition.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4254064611492864848?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4254064611492864848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4254064611492864848' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4254064611492864848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4254064611492864848'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/09/splitting-range-partitioned-table.html' title='Splitting a Range Partitioned Table'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4501905969213421877</id><published>2011-09-03T23:59:00.004+08:00</published><updated>2011-09-07T22:39:56.756+08:00</updated><title type='text'>Understanding Obsolescence of RMAN Backups</title><content type='html'>Questions about the the LIST OBSOLETE command keep appearing in RMAN forums.&lt;br /&gt;&lt;br /&gt;Given this configuration :&lt;br /&gt;&lt;pre&gt;RMAN&amp;gt; show all;&lt;br /&gt;&lt;br /&gt;RMAN configuration parameters for database with db_unique_name ORCL are:&lt;br /&gt;CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 15 DAYS;&lt;br /&gt;CONFIGURE BACKUP OPTIMIZATION OFF;&lt;br /&gt;CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default&lt;br /&gt;CONFIGURE CONTROLFILE AUTOBACKUP ON;&lt;br /&gt;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default&lt;br /&gt;CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;&lt;br /&gt;CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default&lt;br /&gt;CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default&lt;br /&gt;CONFIGURE MAXSETSIZE TO UNLIMITED; # default&lt;br /&gt;CONFIGURE ENCRYPTION FOR DATABASE OFF; # default&lt;br /&gt;CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default&lt;br /&gt;CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default&lt;br /&gt;CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default&lt;br /&gt;CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl.f'; # default&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;which indicates that my Recovery Window is set to 15 days.&lt;br /&gt;&lt;br /&gt;And given this listing of backups :&lt;br /&gt;&lt;pre&gt;RMAN&amp;gt; list backup summary;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;List of Backups&lt;br /&gt;===============&lt;br /&gt;Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag&lt;br /&gt;------- -- -- - ----------- --------------- ------- ------- ---------- ---&lt;br /&gt;130     B  F  A DISK        31-MAY-11       1       1       YES        TAG20110531T224447&lt;br /&gt;132     B  A  A DISK        31-MAY-11       1       1       YES        TAG20110531T224945&lt;br /&gt;133     B  F  A DISK        31-MAY-11       1       1       NO         TAG20110531T224947&lt;br /&gt;134     B  F  A DISK        05-JUL-11       1       1       YES        TAG20110705T230230&lt;br /&gt;135     B  F  A DISK        05-JUL-11       1       1       YES        TAG20110705T230230&lt;br /&gt;136     B  F  A DISK        05-JUL-11       1       1       NO         TAG20110705T230640&lt;br /&gt;137     B  F  A DISK        13-JUL-11       1       1       NO         TAG20110713T224918&lt;br /&gt;138     B  F  A DISK        03-SEP-11       1       1       NO         TAG20110903T232648&lt;br /&gt;139     B  F  A DISK        03-SEP-11       1       1       YES        TAG20110903T234602&lt;br /&gt;140     B  F  A DISK        03-SEP-11       1       1       YES        TAG20110903T234602&lt;br /&gt;141     B  F  A DISK        03-SEP-11       1       1       NO         TAG20110903T235631&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;which backups do you expect to be OBSOLETE ?&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;Why are these reported as OBSOLETE ?&lt;br /&gt;&lt;pre&gt;RMAN&amp;gt; report obsolete;&lt;br /&gt;&lt;br /&gt;RMAN retention policy will be applied to the command&lt;br /&gt;RMAN retention policy is set to recovery window of 15 days&lt;br /&gt;Report of obsolete backups and copies&lt;br /&gt;Type                 Key    Completion Time    Filename/Handle&lt;br /&gt;-------------------- ------ ------------------ --------------------&lt;br /&gt;Backup Set           130    31-MAY-11      &lt;br /&gt;Backup Piece       130    31-MAY-11          /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_05_31/o1_mf_nnndf_TAG20110531T224447_6y9zq1fr_.bkp&lt;br /&gt;Backup Set           132    31-MAY-11      &lt;br /&gt;Backup Piece       132    31-MAY-11          /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_05_31/o1_mf_annnn_TAG20110531T224945_6yb009xg_.bkp&lt;br /&gt;Backup Set           133    31-MAY-11      &lt;br /&gt;Backup Piece       133    31-MAY-11          /addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_05_31/o1_mf_s_752626187_6yb00d1h_.bkp&lt;br /&gt;Backup Set           136    05-JUL-11      &lt;br /&gt;Backup Piece       136    05-JUL-11          /addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_07_05/o1_mf_s_755737600_716b41kb_.bkp&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Why are the Backups in Key 134 and 135 (both on 05-Jul-11) not OBSOLETE ?&lt;br /&gt;(and yet, Key 136 is OBSOLETE)&lt;br /&gt;Why is the Backup of 13-Jul-11 not OBSOLETE ?&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;UPDATE : 05-Sep-11 :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here is some more information :&lt;br /&gt;&lt;pre&gt;sh-3.2$ pwd&lt;br /&gt;/addtl/oracle/flash_recovery_area/ORCL&lt;br /&gt;sh-3.2$ du -sk */*&lt;br /&gt;4       archivelog/2011_08_30&lt;br /&gt;4       archivelog/2011_09_01&lt;br /&gt;4       archivelog/2011_09_02&lt;br /&gt;4       archivelog/2011_09_03&lt;br /&gt;28884   archivelog/2011_09_04&lt;br /&gt;11156   autobackup/2011_04_22&lt;br /&gt;11156   autobackup/2011_05_31&lt;br /&gt;11156   autobackup/2011_07_05&lt;br /&gt;11156   autobackup/2011_07_13&lt;br /&gt;22308   autobackup/2011_09_03&lt;br /&gt;11156   autobackup/2011_09_04&lt;br /&gt;1276    backupset/2011_05_31&lt;br /&gt;677584  backupset/2011_07_05&lt;br /&gt;2951688 backupset/2011_09_03&lt;br /&gt;6400    backupset/2011_09_04&lt;br /&gt;sh-3.2$&lt;br /&gt;sh-3.2$ rman target /&lt;br /&gt;&lt;br /&gt;Recovery Manager: Release 11.2.0.1.0 - Production on Mon Sep 5 22:32:18 2011&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.&lt;br /&gt;&lt;br /&gt;connected to target database: ORCL (DBID=1229390655)&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt; crosscheck backup;&lt;br /&gt;&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=38 device type=DISK&lt;br /&gt;allocated channel: ORA_DISK_2&lt;br /&gt;channel ORA_DISK_2: SID=44 device type=DISK&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_05_31/o1_mf_nnndf_TAG20110531T224447_6y9zq1fr_.bkp RECID=130 STAMP=752625889&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_05_31/o1_mf_annnn_TAG20110531T224945_6yb009xg_.bkp RECID=132 STAMP=752626185&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_05_31/o1_mf_s_752626187_6yb00d1h_.bkp RECID=133 STAMP=752626188&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_07_05/o1_mf_nnndf_TAG20110705T230230_7169w9t3_.bkp RECID=134 STAMP=755737353&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_07_05/o1_mf_nnndf_TAG20110705T230230_7169w8s7_.bkp RECID=135 STAMP=755737352&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_07_05/o1_mf_s_755737600_716b41kb_.bkp RECID=136 STAMP=755737601&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_07_13/o1_mf_s_756427758_71vd3h8n_.bkp RECID=137 STAMP=756427759&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_09_03/o1_mf_s_760922808_764kssdh_.bkp RECID=138 STAMP=760922809&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_03/o1_mf_nnndf_TAG20110903T234602_764lxwdb_.bkp RECID=139 STAMP=760923964&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_03/o1_mf_nnndf_TAG20110903T234602_764lxvd6_.bkp RECID=140 STAMP=760923963&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_09_03/o1_mf_s_760924591_764mkhww_.bkp RECID=141 STAMP=760924591&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_04/o1_mf_annnn_TAG20110904T001454_764nmzy4_.bkp RECID=142 STAMP=760925695&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_04/o1_mf_annnn_TAG20110904T001454_764nmzf8_.bkp RECID=143 STAMP=760925695&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_09_04/o1_mf_s_760925699_764nn3xy_.bkp RECID=144 STAMP=760925699&lt;br /&gt;Crosschecked 14 objects&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;RMAN&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The Backups of 31-May-11 and 05-July-11 are present on disk and found to be AVAILABLE when I run CROSSCHECK.&lt;br /&gt;Also : I have not marked any Backup for KEEPing.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You will also note that RMAN is listing backups that are much older than the control_file_record_keep_time which is 7 days.&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; show parameter control_file_record&lt;br /&gt;&lt;br /&gt;NAME                                 TYPE        VALUE&lt;br /&gt;------------------------------------ ----------- ------------------------------&lt;br /&gt;control_file_record_keep_time        integer     7&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;UPDATE 07-Sep-11 :  Answers &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;BackupSet 136 is OBSOLETEd because it is a Controlfile AutoBackup.  (The listing of LIST BACKUP SUMMARY shows that it is not a Compressed Backup-- controfile autobackups are not compressed -- and the REPORT OBSOLETE shows that it is an autobackup piece).&lt;br /&gt;BackupSets 134 and 135 are *Database* (i.e. Datafile) backups.  These are not obsolete because they comprise the two BackupSets of the most recent BACKUP DATABASE run just before the Retention Policy obsolescence date.  As of 03-Sep, the Retention Policy of 15 days sets a date of 19-Aug.  There was no database backup on  18-Aug or 17-Aug or 16-Aug ... so Oracle works backwards and finds the database backup of 05-July in the BackupSets of 134 and 135.&lt;br /&gt;&lt;br /&gt;Why is it two BackupSets ?  Because I have configured PARALLELISM 2.  Every BACKUP DATABASE command creates two BackupSets. So the run on 05-July created two BackupSets.&lt;br /&gt;&lt;br /&gt;What about the BackupSet (137) of 13-July ? It, too, is a controlfile autobackup.  This is the most recent controlfile autobackup that I have to match the obsolescence date.  So, this canot be OBSOLETEd.&lt;br /&gt;&lt;br /&gt;Also note that backups much older than 7 days (i.e. exceeding the control_file_record_keep_time) are still "maintained" by RMAN -- some of them (e.g. those of 31-May and the controlfile autobackup of 05-July) are OBSOLETE and yet still listed.  They will continue to be listed until I DELETE them.&lt;br /&gt;&lt;br /&gt;Even now, on 07-Sep, the backups are still present :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;[oracle@localhost ORCL]$ pwd&lt;br /&gt;/addtl/oracle/flash_recovery_area/ORCL&lt;br /&gt;[oracle@localhost ORCL]$ du -sk */*&lt;br /&gt;4       archivelog/2011_08_30&lt;br /&gt;4       archivelog/2011_09_01&lt;br /&gt;4       archivelog/2011_09_02&lt;br /&gt;4       archivelog/2011_09_03&lt;br /&gt;28884   archivelog/2011_09_04&lt;br /&gt;26268   archivelog/2011_09_07&lt;br /&gt;11156   autobackup/2011_04_22&lt;br /&gt;11156   autobackup/2011_05_31&lt;br /&gt;11156   autobackup/2011_07_05&lt;br /&gt;11156   autobackup/2011_07_13&lt;br /&gt;22308   autobackup/2011_09_03&lt;br /&gt;11156   autobackup/2011_09_04&lt;br /&gt;1276    backupset/2011_05_31&lt;br /&gt;677584  backupset/2011_07_05&lt;br /&gt;2951688 backupset/2011_09_03&lt;br /&gt;6400    backupset/2011_09_04&lt;br /&gt;[oracle@localhost ORCL]$ &lt;br /&gt;&lt;br /&gt;[oracle@localhost ORCL]$ rman target /&lt;br /&gt;&lt;br /&gt;Recovery Manager: Release 11.2.0.1.0 - Production on Wed Sep 7 22:33:33 2011&lt;br /&gt;&lt;br /&gt;Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.&lt;br /&gt;&lt;br /&gt;connected to target database: ORCL (DBID=1229390655)&lt;br /&gt;&lt;br /&gt;RMAN&gt; crosscheck backup ;&lt;br /&gt;&lt;br /&gt;using target database control file instead of recovery catalog&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=46 device type=DISK&lt;br /&gt;allocated channel: ORA_DISK_2&lt;br /&gt;channel ORA_DISK_2: SID=47 device type=DISK&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_05_31/o1_mf_nnndf_TAG20110531T224447_6y9zq1fr_.bkp RECID=130 STAMP=752625889&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_05_31/o1_mf_annnn_TAG20110531T224945_6yb009xg_.bkp RECID=132 STAMP=752626185&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_05_31/o1_mf_s_752626187_6yb00d1h_.bkp RECID=133 STAMP=752626188&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_07_05/o1_mf_nnndf_TAG20110705T230230_7169w9t3_.bkp RECID=134 STAMP=755737353&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_07_05/o1_mf_nnndf_TAG20110705T230230_7169w8s7_.bkp RECID=135 STAMP=755737352&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_07_05/o1_mf_s_755737600_716b41kb_.bkp RECID=136 STAMP=755737601&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_07_13/o1_mf_s_756427758_71vd3h8n_.bkp RECID=137 STAMP=756427759&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_09_03/o1_mf_s_760922808_764kssdh_.bkp RECID=138 STAMP=760922809&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_03/o1_mf_nnndf_TAG20110903T234602_764lxwdb_.bkp RECID=139 STAMP=760923964&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_03/o1_mf_nnndf_TAG20110903T234602_764lxvd6_.bkp RECID=140 STAMP=760923963&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_09_03/o1_mf_s_760924591_764mkhww_.bkp RECID=141 STAMP=760924591&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_04/o1_mf_annnn_TAG20110904T001454_764nmzy4_.bkp RECID=142 STAMP=760925695&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_04/o1_mf_annnn_TAG20110904T001454_764nmzf8_.bkp RECID=143 STAMP=760925695&lt;br /&gt;crosschecked backup piece: found to be 'AVAILABLE'&lt;br /&gt;backup piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_09_04/o1_mf_s_760925699_764nn3xy_.bkp RECID=144 STAMP=760925699&lt;br /&gt;Crosschecked 14 objects&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;&lt;br /&gt;RMAN&gt; list backup summary;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;List of Backups&lt;br /&gt;===============&lt;br /&gt;Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag&lt;br /&gt;------- -- -- - ----------- --------------- ------- ------- ---------- ---&lt;br /&gt;130     B  F  A DISK        31-MAY-11       1       1       YES        TAG20110531T224447&lt;br /&gt;132     B  A  A DISK        31-MAY-11       1       1       YES        TAG20110531T224945&lt;br /&gt;133     B  F  A DISK        31-MAY-11       1       1       NO         TAG20110531T224947&lt;br /&gt;134     B  F  A DISK        05-JUL-11       1       1       YES        TAG20110705T230230&lt;br /&gt;135     B  F  A DISK        05-JUL-11       1       1       YES        TAG20110705T230230&lt;br /&gt;136     B  F  A DISK        05-JUL-11       1       1       NO         TAG20110705T230640&lt;br /&gt;137     B  F  A DISK        13-JUL-11       1       1       NO         TAG20110713T224918&lt;br /&gt;138     B  F  A DISK        03-SEP-11       1       1       NO         TAG20110903T232648&lt;br /&gt;139     B  F  A DISK        03-SEP-11       1       1       YES        TAG20110903T234602&lt;br /&gt;140     B  F  A DISK        03-SEP-11       1       1       YES        TAG20110903T234602&lt;br /&gt;141     B  F  A DISK        03-SEP-11       1       1       NO         TAG20110903T235631&lt;br /&gt;142     B  A  A DISK        04-SEP-11       1       1       YES        TAG20110904T001454&lt;br /&gt;143     B  A  A DISK        04-SEP-11       1       1       YES        TAG20110904T001454&lt;br /&gt;144     B  F  A DISK        04-SEP-11       1       1       NO         TAG20110904T001459&lt;br /&gt;&lt;br /&gt;RMAN&gt; report obsolete;&lt;br /&gt;&lt;br /&gt;RMAN retention policy will be applied to the command&lt;br /&gt;RMAN retention policy is set to recovery window of 15 days&lt;br /&gt;Report of obsolete backups and copies&lt;br /&gt;Type                 Key    Completion Time    Filename/Handle&lt;br /&gt;-------------------- ------ ------------------ --------------------&lt;br /&gt;Backup Set           130    31-MAY-11         &lt;br /&gt;  Backup Piece       130    31-MAY-11          /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_05_31/o1_mf_nnndf_TAG20110531T224447_6y9zq1fr_.bkp&lt;br /&gt;Backup Set           132    31-MAY-11         &lt;br /&gt;  Backup Piece       132    31-MAY-11          /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_05_31/o1_mf_annnn_TAG20110531T224945_6yb009xg_.bkp&lt;br /&gt;Backup Set           133    31-MAY-11         &lt;br /&gt;  Backup Piece       133    31-MAY-11          /addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_05_31/o1_mf_s_752626187_6yb00d1h_.bkp&lt;br /&gt;Backup Set           136    05-JUL-11         &lt;br /&gt;  Backup Piece       136    05-JUL-11          /addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_07_05/o1_mf_s_755737600_716b41kb_.bkp&lt;br /&gt;&lt;br /&gt;RMAN&gt; &lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So there you have it : &lt;br /&gt;&lt;br /&gt;1. CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 15 DAYS does not necessarily mean that every backup more than 16 days old is obosleted.  Every backup older than the most recent backup before 15 days ago is obsoleted.  If the most recent backup before 15 days from now is 62 days ago (05-July) so be it.  It cannot be OBSOLETEd.&lt;br /&gt;&lt;br /&gt;2.  control_file_record_keep_time of 7 days does not necessarily mean that backups older than 7 days are "purged" from the controlfile or "unknown" to RMAN.  I show some backups (of 31-May and 05-July) that are Obsoleted and yet maintained in the controlfile.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4501905969213421877?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4501905969213421877/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4501905969213421877' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4501905969213421877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4501905969213421877'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/09/understanding-obsolescence-of-rman.html' title='Understanding Obsolescence of RMAN Backups'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4278060794394411617</id><published>2011-08-31T23:17:00.002+08:00</published><updated>2011-08-31T23:26:39.972+08:00</updated><title type='text'>CREATE INDEX ..... PARALLEL</title><content type='html'>We generally use the PARALLEL keyword to speed up index creation thus : &lt;span style="font-family:courier new;"&gt;CREATE INDEX ..... PARALLEL n&lt;/span&gt;.  But also results in the Parallel attribute being set for the index, which means that Oracle may choose to read the index using Parallel Query operators.&lt;br /&gt;If the same index were read by Index Fast Full Scan  by many sessions concurrently, the database instance could end up having many PQ slaves reading the index blocks and not buffering it in the SGA (database cache).  Every user makes a fresh read call for all the index blocks, and they are not cached and reused.&lt;br /&gt;&lt;br /&gt;I generally prefer that every Index be set to NOPARALLEL immediately after creation --- unless it can be proven that Parallel reads of the index would be beneficial.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is a table with 1.6million rows and 50 distinct CUST_IDs :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&gt; select partition_name, num_rows from user_tab_partitions&lt;br /&gt;  2  where table_name = 'SALES_FACT';&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                   NUM_ROWS&lt;br /&gt;------------------------------ ----------&lt;br /&gt;SF_P_2007                          249307&lt;br /&gt;SF_P_2008                          350691&lt;br /&gt;SF_P_2009                          398842&lt;br /&gt;SF_P_2010                          499781&lt;br /&gt;SF_P_2011                          101374&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; drop index sf_cust_b_ndx;&lt;br /&gt;&lt;br /&gt;Index dropped.&lt;br /&gt;&lt;br /&gt;SQL&gt; create bitmap index sf_cust_b_ndx on SALES_FACT(CUST_ID) local parallel 4 nologging;&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&gt;&lt;br /&gt;SQL&gt; explain plan for select distinct cust_id from sales_fact;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 1638564360&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;------------&lt;br /&gt;&lt;br /&gt;| Id  | Operation                         | Name          | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |    TQ  |IN-OUT|&lt;br /&gt;PQ Distrib |&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;------------&lt;br /&gt;&lt;br /&gt;|   0 | SELECT STATEMENT                  |               |    50 |   150 |   356  (14)| 00:00:05 |     |        |        |      |&lt;br /&gt;           |&lt;br /&gt;&lt;br /&gt;|   1 |  PX COORDINATOR                   |               |       |       |            |          |     |        |        |      |&lt;br /&gt;           |&lt;br /&gt;&lt;br /&gt;|   2 |   PX SEND QC (RANDOM)             | :TQ10001      |    50 |   150 |   356  (14)| 00:00:05 |     |        |  Q1,01 | P-&gt;S |&lt;br /&gt;QC (RAND)  |&lt;br /&gt;&lt;br /&gt;|   3 |    HASH UNIQUE                    |               |    50 |   150 |   356  (14)| 00:00:05 |     |        |  Q1,01 | PCWP |&lt;br /&gt;           |&lt;br /&gt;&lt;br /&gt;|   4 |     PX RECEIVE                    |               |  1599K|  4687K|   309   (0)| 00:00:04 |     |        |  Q1,01 | PCWP |&lt;br /&gt;           |&lt;br /&gt;&lt;br /&gt;|   5 |      PX SEND HASH                 | :TQ10000      |  1599K|  4687K|   309   (0)| 00:00:04 |     |        |  Q1,00 | P-&gt;P |&lt;br /&gt;HASH       |&lt;br /&gt;&lt;br /&gt;|   6 |       PX BLOCK ITERATOR           |               |  1599K|  4687K|   309   (0)| 00:00:04 |   1 |      5 |  Q1,00 | PCWC |&lt;br /&gt;           |&lt;br /&gt;&lt;br /&gt;|   7 |        BITMAP INDEX FAST FULL SCAN| SF_CUST_B_NDX |  1599K|  4687K|   309   (0)| 00:00:04 |   1 |      5 |  Q1,00 | PCWP |&lt;br /&gt;           |&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;14 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; alter index sf_cust_b_ndx noparallel;&lt;br /&gt;&lt;br /&gt;Index altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; explain plan for select distinct cust_id from sales_fact;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&gt;  select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 1637766894&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                     | Name          | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |&lt;br /&gt;---------------------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT              |               |    50 |   150 |   356  (14)| 00:00:05 |       |       |&lt;br /&gt;|   1 |  HASH UNIQUE                  |               |    50 |   150 |   356  (14)| 00:00:05 |       |       |&lt;br /&gt;|   2 |   PARTITION RANGE ALL         |               |  1599K|  4687K|   309   (0)| 00:00:04 |     1 |     5 |&lt;br /&gt;|   3 |    BITMAP INDEX FAST FULL SCAN| SF_CUST_B_NDX |  1599K|  4687K|   309   (0)| 00:00:04 |     1 |     5 |&lt;br /&gt;---------------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;10 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Thus, after the Index is created with PARALLEL, the default behaviour for an Index Fast Full Scan is to use Parallel Query.&lt;br /&gt;&lt;br /&gt;What other sorts of queries would use PQ (without having specified a Hint) ?  When would it be beneficial to allow PQ ?&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4278060794394411617?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4278060794394411617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4278060794394411617' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4278060794394411617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4278060794394411617'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/08/create-index-parallel.html' title='CREATE INDEX ..... PARALLEL'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-8524998822550300867</id><published>2011-08-26T23:37:00.002+08:00</published><updated>2011-08-26T23:46:03.356+08:00</updated><title type='text'>Gather Column (Histogram) Stats can use an Index</title><content type='html'>We use the METHOD_OPT parameter to specify columns where we want specific Histograms when running a GATHER_TABLE_STATS.  Oracle can actually make use of an Index to gather such column statistics.&lt;br /&gt;&lt;br /&gt;To demonstrate, I run these statements :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;23:24:40 SQL&gt; exec dbms_session.session_trace_enable;&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:28:46 SQL&gt; exec dbms_stats.gather_table_stats('HEMANT','GTS_DIRECT',-&lt;br /&gt;23:29:01 &gt; method_opt=&gt;'FOR COLUMNS CUST_ID SIZE 250',estimate_percent=&gt;100);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:29:26 SQL&gt; exec dbms_session.session_trace_disable;&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:29:49 SQL&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The trace indicates that these statements are executed :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL ID: 7u3g0tnxmck0n&lt;br /&gt;Plan Hash: 1065175879&lt;br /&gt;select /*+ no_parallel(t) no_parallel_index(t) dbms_stats&lt;br /&gt;  cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring&lt;br /&gt;  no_substrb_pad */count(*), sum(sys_op_opnsize("CUST_ID")),&lt;br /&gt;  sum(sys_op_opnsize("PROD_ID")), count("SALE_QTY"),&lt;br /&gt;  sum(sys_op_opnsize("SALE_QTY")), count("SALE_PRICE"),&lt;br /&gt;  sum(sys_op_opnsize("SALE_PRICE")), count("DISCOUNT_RATE"),&lt;br /&gt;  sum(sys_op_opnsize("DISCOUNT_RATE"))&lt;br /&gt;from&lt;br /&gt; "HEMANT"."GTS_DIRECT" t&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;call     count       cpu    elapsed       disk      query    current        rows&lt;br /&gt;------- ------  -------- ---------- ---------- ---------- ----------  ----------&lt;br /&gt;Parse        1      0.00       0.00          0          0          0           0&lt;br /&gt;Execute      1      0.00       0.00          0          0          0           0&lt;br /&gt;Fetch        2      1.91       2.04      10603      10607          0           1&lt;br /&gt;------- ------  -------- ---------- ---------- ---------- ----------  ----------&lt;br /&gt;total        4      1.91       2.04      10603      10607          0           1&lt;br /&gt;&lt;br /&gt;Misses in library cache during parse: 1&lt;br /&gt;Optimizer mode: ALL_ROWS&lt;br /&gt;Parsing user id: 184     (recursive depth: 1)&lt;br /&gt;&lt;br /&gt;Rows     Row Source Operation&lt;br /&gt;-------  ---------------------------------------------------&lt;br /&gt;      1  SORT AGGREGATE (cr=10607 pr=10603 pw=0 time=0 us)&lt;br /&gt;1599995   TABLE ACCESS FULL GTS_DIRECT (cr=10607 pr=10603 pw=0 time=23223592 us cost=2928 size=55952400 card=1598640)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Elapsed times include waiting on following events:&lt;br /&gt;  Event waited on                             Times   Max. Wait  Total Waited&lt;br /&gt;  ----------------------------------------   Waited  ----------  ------------&lt;br /&gt;  asynch descriptor resize                        2        0.00          0.00&lt;br /&gt;********************************************************************************&lt;br /&gt;&lt;br /&gt;SQL ID: gqcrdy9818rwv&lt;br /&gt;Plan Hash: 585751186&lt;br /&gt;select substrb(dump(val,16,0,32),1,120) ep, cnt&lt;br /&gt;from&lt;br /&gt; (select /*+ no_parallel(t) no_parallel_index(t) dbms_stats&lt;br /&gt;  cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring&lt;br /&gt;  no_substrb_pad */"CUST_ID" val,count(*) cnt  from "HEMANT"."GTS_DIRECT" t&lt;br /&gt;  where "CUST_ID" is not null  group by "CUST_ID") order by val&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;call     count       cpu    elapsed       disk      query    current        rows&lt;br /&gt;------- ------  -------- ---------- ---------- ---------- ----------  ----------&lt;br /&gt;Parse        1      0.00       0.00          0          0          0           0&lt;br /&gt;Execute      1      0.00       0.00          0          0          0           0&lt;br /&gt;Fetch       51      1.18       1.39       3132       3144          0          50&lt;br /&gt;------- ------  -------- ---------- ---------- ---------- ----------  ----------&lt;br /&gt;total       53      1.18       1.39       3132       3144          0          50&lt;br /&gt;&lt;br /&gt;Misses in library cache during parse: 1&lt;br /&gt;Optimizer mode: ALL_ROWS&lt;br /&gt;Parsing user id: 184     (recursive depth: 1)&lt;br /&gt;&lt;br /&gt;Rows     Row Source Operation&lt;br /&gt;-------  ---------------------------------------------------&lt;br /&gt;     50  SORT GROUP BY (cr=3144 pr=3132 pw=0 time=0 us cost=911 size=150 card=50)&lt;br /&gt;1599995   INDEX FAST FULL SCAN GTS_DIRECT_CUST_NDX (cr=3144 pr=3132 pw=0 time=122696624 us cost=864 size=4795920 card=1598640)(object id 87367)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Elapsed times include waiting on following events:&lt;br /&gt;  Event waited on                             Times   Max. Wait  Total Waited&lt;br /&gt;  ----------------------------------------   Waited  ----------  ------------&lt;br /&gt;  db file scattered read                         40        0.01          0.15&lt;br /&gt;********************************************************************************&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Thus, Oracle used the GTS_DIRECT_CUST_NDX on the CUST_ID column.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-8524998822550300867?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/8524998822550300867/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=8524998822550300867' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/8524998822550300867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/8524998822550300867'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/08/gather-column-histogram-stats-can-use.html' title='Gather Column (Histogram) Stats can use an Index'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4103696013225137778</id><published>2011-08-25T23:19:00.002+08:00</published><updated>2011-08-25T23:48:55.306+08:00</updated><title type='text'>Does GATHER_TABLE_STATS update Index Statistics ?</title><content type='html'>In 9i, the GATHER_TABLE_STATS procedure would default CASCADE to FALSE.&lt;br /&gt;In 10g and 11g, the procedure defaults CASCADE to AUTO.&lt;br /&gt;In theory, you would expect that if the optimizer knows that the number of updates to the index since the last gather index stats is not significant, the AUTO behaviour for CASCADE would mean that Oracle would not include Indexes when running a GATHER_TABLE_STATS.&lt;br /&gt;(Of course, if the Index statistics are old and there has been significant DML since then, AUTO would cause Index statistics to be gathered).&lt;br /&gt;&lt;br /&gt;Here's a test in 11.2 (11.2.0.1) :&lt;br /&gt;&lt;br /&gt;First I confirm that my CASCADE still defaults to AUTO :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&gt; select dbms_stats.get_prefs('CASCADE') from dual;&lt;br /&gt;&lt;br /&gt;DBMS_STATS.GET_PREFS('CASCADE')&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;DBMS_STATS.AUTO_CASCADE&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Next I run two tests whereby &lt;br /&gt;a) I CREATE INDEX *after* the table is populated -- so the CREATE INDEX does it's own GATHER_INDEX_STATS&lt;br /&gt;b) I run GATHER_TABLE_STATS&lt;br /&gt;c) I then verify if the GATHER_TABLE_STATS did re-gather index stats&lt;br /&gt;&lt;br /&gt;In the first test, the table is populated via "normal" DML.  In the second test, the table is populated via a Direct Path INSERT.&lt;br /&gt;&lt;br /&gt;However (surprisingly ??) I find that although the CREATE INDEX has actually populated the Index Statistics with 100% sampling, the subsequent call to GATHER_TABLE_STATS seems to re-gather Index Statistics !&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;23:28:10 SQL&gt; alter session set nls_date_format='DD-MON-RR HH24:MI:SS';&lt;br /&gt;&lt;br /&gt;Session altered.&lt;br /&gt;&lt;br /&gt;23:28:10 SQL&gt; &lt;br /&gt;23:28:10 SQL&gt; REM REM ##########################################&lt;br /&gt;23:28:10 SQL&gt; REM       -- This table has data inserted normally&lt;br /&gt;23:28:10 SQL&gt; &lt;br /&gt;23:28:10 SQL&gt; create table GTS_NORMAL as select * from sales_fact where 1=2;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;23:28:10 SQL&gt; insert into GTS_NORMAL select * from sales_fact;&lt;br /&gt;&lt;br /&gt;1599995 rows created.&lt;br /&gt;&lt;br /&gt;23:28:17 SQL&gt; create index GTS_NORMAL_CUST_NDX on GTS_NORMAL (CUST_ID);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;23:28:27 SQL&gt; -- check existing statistics&lt;br /&gt;23:28:27 SQL&gt; select table_name Object_name, num_rows, last_analyzed&lt;br /&gt;23:28:27   2  from user_tables&lt;br /&gt;23:28:27   3  where table_name = 'GTS_NORMAL'&lt;br /&gt;23:28:27   4  union&lt;br /&gt;23:28:27   5  select index_name Object_name, num_rows, last_analyzed&lt;br /&gt;23:28:27   6  from user_indexes&lt;br /&gt;23:28:27   7  where table_name = 'GTS_NORMAL'&lt;br /&gt;23:28:27   8  /&lt;br /&gt;&lt;br /&gt;OBJECT_NAME                      NUM_ROWS LAST_ANALYZED&lt;br /&gt;------------------------------ ---------- ------------------&lt;br /&gt;GTS_NORMAL&lt;br /&gt;GTS_NORMAL_CUST_NDX               1599995 25-AUG-11 23:28:27&lt;br /&gt;&lt;br /&gt;23:28:27 SQL&gt; exec dbms_lock.sleep(180);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:31:28 SQL&gt; -- gather statistics&lt;br /&gt;23:31:28 SQL&gt; exec dbms_stats.gather_table_stats('','GTS_NORMAL',estimate_percent=&gt;30,degree=&gt;2);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:31:37 SQL&gt; -- recheck statistics&lt;br /&gt;23:31:37 SQL&gt; select table_name Object_name, num_rows, last_analyzed&lt;br /&gt;23:31:37   2  from user_tables&lt;br /&gt;23:31:37   3  where table_name = 'GTS_NORMAL'&lt;br /&gt;23:31:37   4  union&lt;br /&gt;23:31:37   5  select index_name Object_name, num_rows, last_analyzed&lt;br /&gt;23:31:37   6  from user_indexes&lt;br /&gt;23:31:37   7  where table_name = 'GTS_NORMAL'&lt;br /&gt;23:31:37   8  /&lt;br /&gt;&lt;br /&gt;OBJECT_NAME                      NUM_ROWS LAST_ANALYZED&lt;br /&gt;------------------------------ ---------- ------------------&lt;br /&gt;GTS_NORMAL                        1597223 25-AUG-11 23:31:36&lt;br /&gt;GTS_NORMAL_CUST_NDX               1572991 25-AUG-11 23:31:37&lt;br /&gt;&lt;br /&gt;23:31:37 SQL&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The CREATE INDEX had gathered index statistics with 100% sampling and presenting the correct NUM_ROWS count at 23:28:27.   However, the GATHER_TABLE_STATS re-updated Index Statistics as well, this time using the 30% sampling !  It overwrote the Index statistics that had ben gathered only 3minutes earlier (with no new DML occurring in-between !).&lt;br /&gt;&lt;br /&gt;Here's the test with a table where DIRECT PATH INSERT is used :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;23:31:37 SQL&gt; REM REM ##########################################&lt;br /&gt;23:31:37 SQL&gt; REM       -- This table has data inserted via DirectPath&lt;br /&gt;23:31:37 SQL&gt; &lt;br /&gt;23:31:37 SQL&gt; create table GTS_DIRECT as select * from sales_fact where 1=2;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;23:31:37 SQL&gt; insert /*+ APPEND */  into GTS_DIRECT select * from sales_fact;&lt;br /&gt;&lt;br /&gt;1599995 rows created.&lt;br /&gt;&lt;br /&gt;23:31:44 SQL&gt; create index GTS_DIRECT_CUST_NDX on GTS_DIRECT (CUST_ID);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;23:31:57 SQL&gt; -- check existing statistics&lt;br /&gt;23:31:57 SQL&gt; select table_name Object_name, num_rows, last_analyzed&lt;br /&gt;23:31:57   2  from user_tables&lt;br /&gt;23:31:57   3  where table_name = 'GTS_DIRECT'&lt;br /&gt;23:31:57   4  union&lt;br /&gt;23:31:57   5  select index_name Object_name, num_rows, last_analyzed&lt;br /&gt;23:31:57   6  from user_indexes&lt;br /&gt;23:31:57   7  where table_name = 'GTS_DIRECT'&lt;br /&gt;23:31:57   8  /&lt;br /&gt;&lt;br /&gt;OBJECT_NAME                      NUM_ROWS LAST_ANALYZED&lt;br /&gt;------------------------------ ---------- ------------------&lt;br /&gt;GTS_DIRECT&lt;br /&gt;GTS_DIRECT_CUST_NDX               1599995 25-AUG-11 23:31:57&lt;br /&gt;&lt;br /&gt;23:31:57 SQL&gt; exec dbms_lock.sleep(180);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:34:58 SQL&gt; -- gather statistics&lt;br /&gt;23:34:58 SQL&gt; exec dbms_stats.gather_table_stats('','GTS_DIRECT',estimate_percent=&gt;30,degree=&gt;2);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:35:06 SQL&gt; -- recheck statistics&lt;br /&gt;23:35:06 SQL&gt; select table_name Object_name, num_rows, last_analyzed&lt;br /&gt;23:35:06   2  from user_tables&lt;br /&gt;23:35:06   3  where table_name = 'GTS_DIRECT'&lt;br /&gt;23:35:06   4  union&lt;br /&gt;23:35:06   5  select index_name Object_name, num_rows, last_analyzed&lt;br /&gt;23:35:06   6  from user_indexes&lt;br /&gt;23:35:06   7  where table_name = 'GTS_DIRECT'&lt;br /&gt;23:35:06   8  /&lt;br /&gt;&lt;br /&gt;OBJECT_NAME                      NUM_ROWS LAST_ANALYZED&lt;br /&gt;------------------------------ ---------- ------------------&lt;br /&gt;GTS_DIRECT                        1599103 25-AUG-11 23:35:04&lt;br /&gt;GTS_DIRECT_CUST_NDX               1645512 25-AUG-11 23:35:06&lt;br /&gt;&lt;br /&gt;23:35:06 SQL&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Again, the GATHER_TABLE_STATS resulted in a fresh gathering of Index Statistics, overwriting those that the CREATE INDEX had meticulously done  !&lt;br /&gt;&lt;br /&gt;What if I try again after some time ?&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;23:43:04 SQL&gt; exec dbms_stats.gather_table_stats('','GTS_NORMAL',estimate_percent=&gt;30,degree=&gt;2);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:43:24 SQL&gt; select table_name Object_name, num_rows, last_analyzed&lt;br /&gt;from user_tables&lt;br /&gt;where table_name = 'GTS_NORMAL'&lt;br /&gt;union&lt;br /&gt;select index_name Object_name, num_rows, last_analyzed&lt;br /&gt;from user_indexes&lt;br /&gt;where table_name = 'GTS_NORMAL'&lt;br /&gt;/&lt;br /&gt;23:43:55   2  23:43:55   3  23:43:55   4  23:43:55   5  23:43:55   6  23:43:55   7  23:43:55   8  &lt;br /&gt;OBJECT_NAME                      NUM_ROWS LAST_ANALYZED&lt;br /&gt;------------------------------ ---------- ------------------&lt;br /&gt;GTS_NORMAL                        1597310 25-AUG-11 23:43:23&lt;br /&gt;GTS_NORMAL_CUST_NDX               1594325 25-AUG-11 23:43:24&lt;br /&gt;&lt;br /&gt;23:43:55 SQL&gt; &lt;br /&gt;23:43:55 SQL&gt; exec dbms_stats.gather_table_stats('','GTS_DIRECT',estimate_percent=&gt;30,degree=&gt;2);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;23:44:58 SQL&gt; select table_name Object_name, num_rows, last_analyzed&lt;br /&gt;from user_tables&lt;br /&gt;where table_name = 'GTS_DIRECT'&lt;br /&gt;union&lt;br /&gt;select index_name Object_name, num_rows, last_analyzed&lt;br /&gt;from user_indexes&lt;br /&gt;where table_name = 'GTS_DIRECT'&lt;br /&gt;/&lt;br /&gt;23:45:13   2  23:45:13   3  23:45:13   4  23:45:13   5  23:45:13   6  23:45:13   7  23:45:13   8  &lt;br /&gt;OBJECT_NAME                      NUM_ROWS LAST_ANALYZED&lt;br /&gt;------------------------------ ---------- ------------------&lt;br /&gt;GTS_DIRECT                        1598393 25-AUG-11 23:44:57&lt;br /&gt;GTS_DIRECT_CUST_NDX               1629881 25-AUG-11 23:44:58&lt;br /&gt;&lt;br /&gt;23:45:13 SQL&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, a run of DBMS_STATS.GATHER_TABLE_STATS seems to re-gather Index Statistics, even if Index Statistics are very fresh and do not need to be updated.  What gives ? Why does AUTO_CASCADE behave in this manner ?&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4103696013225137778?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4103696013225137778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4103696013225137778' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4103696013225137778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4103696013225137778'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/08/does-gathertablestats-update-index.html' title='Does GATHER_TABLE_STATS update Index Statistics ?'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4352711061646730397</id><published>2011-08-21T23:13:00.004+08:00</published><updated>2011-08-22T22:20:00.223+08:00</updated><title type='text'>Reading an AWR Report  --  3</title><content type='html'>Continuing the Reading an AWR report series ....&lt;br /&gt;&lt;br /&gt;I run these statements :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; exec dbms_workload_repository.create_snapshot;&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;Elapsed: 00:00:01.15&lt;br /&gt;SQL&amp;gt; set serveroutput on&lt;br /&gt;SQL&amp;gt; declare&lt;br /&gt;2  cnt   number;&lt;br /&gt;3  begin&lt;br /&gt;4  select sum(sale_qty) into cnt&lt;br /&gt;5  from very_large_fact_table&lt;br /&gt;6  where prod_id = 5;&lt;br /&gt;7  dbms_output.put_line('Sales for Prod 5     : ' || cnt);&lt;br /&gt;8  select sum(sale_qty) into cnt&lt;br /&gt;9  from very_large_fact_table&lt;br /&gt;10  where prod_id  in (4,11);&lt;br /&gt;11  dbms_output.put_line('Sales for Prods 4,11 : ' || cnt);&lt;br /&gt;12  select sum(sale_qty) into cnt&lt;br /&gt;13  from very_large_fact_table&lt;br /&gt;14  where prod_id  = 10&lt;br /&gt;15  and cust_id = 10;&lt;br /&gt;16  dbms_output.put_line('Sales for Prod 10 to Cust 10 : ' || cnt);&lt;br /&gt;17  end;&lt;br /&gt;18  /&lt;br /&gt;Sales for Prod 5  : 4012173200&lt;br /&gt;Sales for Prods 4,11 : 8004026720&lt;br /&gt;Sales for Prod 10 to Cust 10 : 2017249360&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;Elapsed: 00:01:34.05&lt;br /&gt;SQL&amp;gt; exec dbms_workload_repository.create_snapshot;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The AWR report indicates that the whole PLSQL block took 57.47 seconds  but that the individual SQLs in the block took 70.52 to 112.95 seconds (Note :The client reported a total elapsed time of 94.05seconds, including parsing and SQLNet time !).&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;SQL ordered by Elapsed Time              DB/Inst: ORCL/orcl  Snaps: 1320-1321&lt;br /&gt;-&amp;gt; Resources reported for PL/SQL code includes the resources used by all SQL&lt;br /&gt;statements called by the code.&lt;br /&gt;-&amp;gt; % Total DB Time is the Elapsed Time of the SQL statement divided&lt;br /&gt;into the Total Database Time multiplied by 100&lt;br /&gt;-&amp;gt; %Total - Elapsed Time  as a percentage of Total DB time&lt;br /&gt;-&amp;gt; %CPU   - CPU Time      as a percentage of Elapsed Time&lt;br /&gt;-&amp;gt; %IO    - User I/O Time as a percentage of Elapsed Time&lt;br /&gt;-&amp;gt; Captured SQL account for   99.7% of Total DB Time (s):             284&lt;br /&gt;-&amp;gt; Captured PL/SQL account for   20.7% of Total DB Time (s):             284&lt;br /&gt;&lt;br /&gt;     Elapsed                  Elapsed Time&lt;br /&gt;     Time (s)    Executions  per Exec (s)  %Total   %CPU    %IO    SQL Id&lt;br /&gt;---------------- -------------- ------------- ------ ------ ------ -------------&lt;br /&gt;        112.9              1        112.95   39.8   23.5     .4 cc8khw75jw0ha&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;SELECT SUM(SALE_QTY) FROM VERY_LARGE_FACT_TABLE WHERE PROD_ID = 10 AND CUST_ID =&lt;br /&gt;10&lt;br /&gt;&lt;br /&gt;         97.2              1         97.22   34.3   34.7    1.1 dwm8pq8awt96v&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;SELECT SUM(SALE_QTY) FROM VERY_LARGE_FACT_TABLE WHERE PROD_ID IN (4,11)&lt;br /&gt;&lt;br /&gt;         70.5              1         70.52   24.9   37.2     .6 gscvdz32smtgr&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;SELECT SUM(SALE_QTY) FROM VERY_LARGE_FACT_TABLE WHERE PROD_ID = 5&lt;br /&gt;&lt;br /&gt;         57.5              1         57.47   20.3     .3     .0 1dh6uf6hyr3us&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;declare cnt number; begin select sum(sale_qty) into cnt from very_large_fact_t&lt;br /&gt;able where prod_id = 5; dbms_output.put_line('Sales for Prod 5 : ' || cnt); sel&lt;br /&gt;ect sum(sale_qty) into cnt from very_large_fact_table where prod_id in (4,11);&lt;br /&gt;dbms_output.put_line('Sales for Prods 4,11 : ' || cnt); select sum(sale_qty) int&lt;br /&gt;&lt;br /&gt;          1.1              1          1.14     .4   88.2   10.6 1uk5m5qbzj1vt&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;BEGIN dbms_workload_repository.create_snapshot; END;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The table has a PARALLEL DEGREE of 4 defined so each of the three queries, doing a FullTableScan actually used 4 PQ slaves.&lt;br /&gt;&lt;br /&gt;What are the time model statistics ?&lt;br /&gt;&lt;pre&gt;Time Model Statistics                    DB/Inst: ORCL/orcl  Snaps: 1320-1321&lt;br /&gt;-&amp;gt; Total time in database user-calls (DB Time): 283.5s&lt;br /&gt;-&amp;gt; Statistics including the word "background" measure background process&lt;br /&gt;time, and so do not contribute to the DB time statistic&lt;br /&gt;-&amp;gt; Ordered by % or DB time desc, Statistic name&lt;br /&gt;&lt;br /&gt;Statistic Name                                       Time (s) % of DB Time&lt;br /&gt;------------------------------------------ ------------------ ------------&lt;br /&gt;sql execute elapsed time                                281.8         99.4&lt;br /&gt;DB CPU                                                   88.2         31.1&lt;br /&gt;parse time elapsed                                        0.4           .1&lt;br /&gt;PL/SQL execution elapsed time                             0.2           .1&lt;br /&gt;hard parse elapsed time                                   0.2           .1&lt;br /&gt;hard parse (sharing criteria) elapsed time                0.1           .0&lt;br /&gt;PL/SQL compilation elapsed time                           0.0           .0&lt;br /&gt;repeated bind elapsed time                                0.0           .0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The Time Model Statistics indicates that the summed elapsed time for all sessions (including PQ slaves) is 281.8seconds and the summed DB CPU t ime is 88.2seconds.&lt;br /&gt;&lt;br /&gt;The Timed Foreground Events shows :&lt;br /&gt;&lt;pre&gt;                                                          Avg&lt;br /&gt;                                                       wait   % DB&lt;br /&gt;Event                                 Waits     Time(s)   (ms)   time Wait Class&lt;br /&gt;------------------------------ ------------ ----------- ------ ------ ----------&lt;br /&gt;DB CPU                                               88          31.1&lt;br /&gt;direct path read                         61           2     31     .7 User I/O&lt;br /&gt;cursor: pin S wait on X                   3           0     67     .1 Concurrenc&lt;br /&gt;PX Deq: Signal ACK RSG                    2           0     89     .1 Other&lt;br /&gt;db file sequential read                  50           0      4     .1 User I/O&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If Database CPU time was 88.2seconds and total Database SQL Elapsed Time was 281.8seconds, how do we account for the large discrepancy ?  All the other wait event hardly add up to a few seconds.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;UPDATE 22-Aug-11 :&lt;/span&gt;&lt;br /&gt;What if the table is set to NOPARALLEL so that the the three SQL executions do not use Parallel Query slaves ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select degree from user_tables where table_name = 'VERY_LARGE_FACT_TABLE';&lt;br /&gt;&lt;br /&gt;DEGREE&lt;br /&gt;----------------------------------------&lt;br /&gt;        4&lt;br /&gt;&lt;br /&gt;Elapsed: 00:00:00.18&lt;br /&gt;SQL&amp;gt; alter table very_large_fact_table noparallel;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;Elapsed: 00:00:00.73&lt;br /&gt;SQL&amp;gt; select degree from user_tables where table_name = 'VERY_LARGE_FACT_TABLE';&lt;br /&gt;&lt;br /&gt;DEGREE&lt;br /&gt;----------------------------------------&lt;br /&gt;        1&lt;br /&gt;&lt;br /&gt;Elapsed: 00:00:00.01&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; exec dbms_workload_repository.create_snapshot;&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;Elapsed: 00:00:03.13&lt;br /&gt;SQL&amp;gt; set serveroutput on&lt;br /&gt;SQL&amp;gt; declare&lt;br /&gt; 2  cnt   number;&lt;br /&gt; 3  begin&lt;br /&gt; 4  select sum(sale_qty) into cnt&lt;br /&gt; 5  from very_large_fact_table&lt;br /&gt; 6  where prod_id = 5;&lt;br /&gt; 7  dbms_output.put_line('Sales for Prod 5     : ' || cnt);&lt;br /&gt; 8  select sum(sale_qty) into cnt&lt;br /&gt; 9  from very_large_fact_table&lt;br /&gt;10  where prod_id  in (4,11);&lt;br /&gt;11  dbms_output.put_line('Sales for Prods 4,11 : ' || cnt);&lt;br /&gt;12  select sum(sale_qty) into cnt&lt;br /&gt;13  from very_large_fact_table&lt;br /&gt;14  where prod_id  = 10&lt;br /&gt;15  and cust_id = 10;&lt;br /&gt;16  dbms_output.put_line('Sales for Prod 10 to Cust 10 : ' || cnt);&lt;br /&gt;17  end;&lt;br /&gt;18  /&lt;br /&gt;Sales for Prod 5  : 4012173200&lt;br /&gt;Sales for Prods 4,11 : 8004026720&lt;br /&gt;Sales for Prod 10 to Cust 10 : 2017249360&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;Elapsed: 00:02:31.73&lt;br /&gt;SQL&amp;gt; exec dbms_workload_repository.create_snapshot;&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;Elapsed: 00:00:01.43&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, the entire block completed in 151.73seconds.&lt;br /&gt;&lt;br /&gt;What does the AWR report show ?&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;SQL ordered by Elapsed Time              DB/Inst: ORCL/orcl  Snaps: 1325-1326&lt;br /&gt;-&amp;gt; Resources reported for PL/SQL code includes the resources used by all SQL&lt;br /&gt;  statements called by the code.&lt;br /&gt;-&amp;gt; % Total DB Time is the Elapsed Time of the SQL statement divided&lt;br /&gt;  into the Total Database Time multiplied by 100&lt;br /&gt;-&amp;gt; %Total - Elapsed Time  as a percentage of Total DB time&lt;br /&gt;-&amp;gt; %CPU   - CPU Time      as a percentage of Elapsed Time&lt;br /&gt;-&amp;gt; %IO    - User I/O Time as a percentage of Elapsed Time&lt;br /&gt;-&amp;gt; Captured SQL account for   94.2% of Total DB Time (s):             167&lt;br /&gt;-&amp;gt; Captured PL/SQL account for   94.0% of Total DB Time (s):             167&lt;br /&gt;&lt;br /&gt;       Elapsed                  Elapsed Time&lt;br /&gt;       Time (s)    Executions  per Exec (s)  %Total   %CPU    %IO    SQL Id&lt;br /&gt;---------------- -------------- ------------- ------ ------ ------ -------------&lt;br /&gt;          151.7              1        151.70   91.1   62.6   19.1 1dh6uf6hyr3us&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;declare cnt number; begin select sum(sale_qty) into cnt from very_large_fact_t&lt;br /&gt;able where prod_id = 5; dbms_output.put_line('Sales for Prod 5 : ' || cnt); sel&lt;br /&gt;ect sum(sale_qty) into cnt from very_large_fact_table where prod_id in (4,11);&lt;br /&gt;dbms_output.put_line('Sales for Prods 4,11 : ' || cnt); select sum(sale_qty) int&lt;br /&gt;&lt;br /&gt;           58.9              1         58.87   35.3   64.2   17.0 dwm8pq8awt96v&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;SELECT SUM(SALE_QTY) FROM VERY_LARGE_FACT_TABLE WHERE PROD_ID IN (4,11)&lt;br /&gt;&lt;br /&gt;           46.8              1         46.79   28.1   61.6   26.1 cc8khw75jw0ha&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;SELECT SUM(SALE_QTY) FROM VERY_LARGE_FACT_TABLE WHERE PROD_ID = 10 AND CUST_ID =&lt;br /&gt;10&lt;br /&gt;&lt;br /&gt;           46.0              1         45.99   27.6   61.6   14.5 gscvdz32smtgr&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;SELECT SUM(SALE_QTY) FROM VERY_LARGE_FACT_TABLE WHERE PROD_ID = 5&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Isn't that a very interesting difference from yesterday's report ?  Now we have the real execution time for each of the three SQLs which add up to the time for the PLSQL block. &lt;br /&gt;&lt;br /&gt;Is there a discrepancy in the Time Model Statistics now ?&lt;br /&gt;&lt;pre&gt;Time Model Statistics                    DB/Inst: ORCL/orcl  Snaps: 1325-1326&lt;br /&gt;-&amp;gt; Total time in database user-calls (DB Time): 166.6s&lt;br /&gt;-&amp;gt; Statistics including the word "background" measure background process&lt;br /&gt;  time, and so do not contribute to the DB time statistic&lt;br /&gt;-&amp;gt; Ordered by % or DB time desc, Statistic name&lt;br /&gt;&lt;br /&gt;Statistic Name                                       Time (s) % of DB Time&lt;br /&gt;------------------------------------------ ------------------ ------------&lt;br /&gt;sql execute elapsed time                                161.7         97.1&lt;br /&gt;DB CPU                                                   99.4         59.7&lt;br /&gt;parse time elapsed                                        2.8          1.7&lt;br /&gt;PL/SQL execution elapsed time                             2.6          1.6&lt;br /&gt;hard parse elapsed time                                   2.2          1.3&lt;br /&gt;hard parse (sharing criteria) elapsed time                0.2           .1&lt;br /&gt;PL/SQL compilation elapsed time                           0.0           .0&lt;br /&gt;repeated bind elapsed time                                0.0           .0&lt;br /&gt;sequence load elapsed time                                0.0           .0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Top 5 Timed Foreground Events&lt;br /&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;                                                          Avg&lt;br /&gt;                                                         wait   % DB&lt;br /&gt;Event                                 Waits     Time(s)   (ms)   time Wait Class&lt;br /&gt;------------------------------ ------------ ----------- ------ ------ ----------&lt;br /&gt;DB CPU                                               99          59.7&lt;br /&gt;direct path read                      4,648          27      6   16.5 User I/O&lt;br /&gt;db file sequential read                 388           1      4     .9 User I/O&lt;br /&gt;db file scattered read                   18           1     36     .4 User I/O&lt;br /&gt;enq: KO - fast object checkpoi            1           0     53     .0 Applicatio&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What are your comments / observations ?&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4352711061646730397?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4352711061646730397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4352711061646730397' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4352711061646730397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4352711061646730397'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/08/reading-awr-report-3.html' title='Reading an AWR Report  --  3'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-2808965264955146394</id><published>2011-08-10T23:25:00.002+08:00</published><updated>2011-08-10T23:30:45.132+08:00</updated><title type='text'>Singapore RACSIG meeting today</title><content type='html'>Today's Singapore RACSIG meeting went well.   Ravi brought up a "problem" case in RAC Architecture which we discussed for some time.  Next was a review of GoldenGate.  Here, too, there were many questions and many answers !&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We plan to have another workshop in September.  Stay Tuned !&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://apex.oracle.com/pls/otn/f?p=19297:4:7352396975799172::NO:4:P4_ID:700"&gt;Piet de Visser&lt;/a&gt; was a guest at our meeting today.  I am sure he was happy to have attended the meeting and participated in the discussions.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-2808965264955146394?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/2808965264955146394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=2808965264955146394' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2808965264955146394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2808965264955146394'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/08/singapore-racsig-meeting-today.html' title='Singapore RACSIG meeting today'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-59442491170508722</id><published>2011-08-09T23:41:00.004+08:00</published><updated>2011-08-13T12:39:56.898+08:00</updated><title type='text'>Reading an AWR  -- 2</title><content type='html'>I have extracted this from an AWR report :&lt;br /&gt;&lt;pre&gt;    &lt;br /&gt;    Elapsed                  Elapsed Time&lt;br /&gt;    Time (s)    Executions  per Exec (s)  %Total   %CPU    %IO    SQL Id&lt;br /&gt;---------------- -------------- ------------- ------ ------ ------ -------------&lt;br /&gt;       277.8              1        277.85   97.6   14.9   59.4 8madvr3cvp929&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;select count(*), sum(sale_qty), sum(discount_rate) from very_large_fact_table&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; CPU                   CPU per           Elapsed&lt;br /&gt;Time (s)  Executions    Exec (s) %Total   Time (s)   %CPU    %IO    SQL Id&lt;br /&gt;---------- ------------ ---------- ------ ---------- ------ ------ -------------&lt;br /&gt;   41.5            1      41.49   91.4      277.8   14.9   59.4 8madvr3cvp929&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;select count(*), sum(sale_qty), sum(discount_rate) from very_large_fact_table&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;User I/O                UIO per           Elapsed&lt;br /&gt;Time (s)  Executions    Exec (s) %Total   Time (s)   %CPU    %IO    SQL Id&lt;br /&gt;---------- ------------ ---------- ------ ---------- ------ ------ -------------&lt;br /&gt;  164.9            1     164.94   99.4      277.8   14.9   59.4 8madvr3cvp929&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;select count(*), sum(sale_qty), sum(discount_rate) from very_large_fact_table&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  Buffer                 Gets              Elapsed&lt;br /&gt;   Gets   Executions   per Exec   %Total   Time (s)   %CPU    %IO    SQL Id&lt;br /&gt;----------- ----------- ------------ ------ ---------- ------ ------ -----------&lt;br /&gt; 530,607           1    530,607.0   98.0      277.8   14.9   59.4 8madvr3cvp9&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;select count(*), sum(sale_qty), sum(discount_rate) from very_large_fact_table&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Physical              Reads              Elapsed&lt;br /&gt;   Reads  Executions per Exec   %Total   Time (s)   %CPU    %IO    SQL Id&lt;br /&gt;----------- ----------- ---------- ------ ---------- ------ ------ -------------&lt;br /&gt; 530,326           1  530,326.0   99.9      277.8   14.9   59.4 8madvr3cvp929&lt;br /&gt;Module: SQL*Plus&lt;br /&gt;select count(*), sum(sale_qty), sum(discount_rate) from very_large_fact_table&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;How long did the query really take to execute ?  Did it take approximately 278seconds ?  We know that the query returns only 1 row so we don't have to factor SQL*Net round-trips or ARRAYSIZE.  This is the output of the query :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select count(*), sum(sale_qty), sum(discount_rate)&lt;br /&gt;2  from very_large_fact_table&lt;br /&gt;3  /&lt;br /&gt;&lt;br /&gt;COUNT(*) SUM(SALE_QTY) SUM(DISCOUNT_RATE)&lt;br /&gt;---------- ------------- ------------------&lt;br /&gt;80000000    1.0044E+11         1280636517&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;A query on 80million rows and about 530thousand blocks (slightly over 4GB).  Did it take about 278seconds to execute ?&lt;br /&gt;&lt;br /&gt;??&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;UPDATE : 13-Aug :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here is the actual execution of the query (with elapsed time included) :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select count(*), sum(sale_qty), sum(discount_rate)&lt;br /&gt; 2  from very_large_fact_table&lt;br /&gt; 3  /&lt;br /&gt;&lt;br /&gt; COUNT(*) SUM(SALE_QTY) SUM(DISCOUNT_RATE)&lt;br /&gt;---------- ------------- ------------------&lt;br /&gt; 80000000    1.0044E+11         1280636517&lt;br /&gt;&lt;br /&gt;Elapsed: 00:01:11.95&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, the actual elapsed time was about 72seconds. &lt;br /&gt;How did the query really execute ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select * from table(dbms_xplan.display_cursor);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;SQL_ID  8madvr3cvp929, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select count(*), sum(sale_qty), sum(discount_rate) from&lt;br /&gt;very_large_fact_table&lt;br /&gt;&lt;br /&gt;Plan hash value: 3187774711&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation              | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |&lt;br /&gt;-----------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT       |                       |       |       | 40148 (100)|          |        |      |            |&lt;br /&gt;|   1 |  SORT AGGREGATE        |                       |     1 |    26 |            |          |        |      |            |&lt;br /&gt;|   2 |   PX COORDINATOR       |                       |       |       |            |          |        |      |            |&lt;br /&gt;|   3 |    PX SEND QC (RANDOM) | :TQ10000              |     1 |    26 |            |          |  Q1,00 | P-&amp;gt;S | QC (RAND)  |&lt;br /&gt;|   4 |     SORT AGGREGATE     |                       |     1 |    26 |            |          |  Q1,00 | PCWP |            |&lt;br /&gt;|   5 |      PX BLOCK ITERATOR |                       |    87M|  2176M| 40148   (1)| 00:08:02 |  Q1,00 | PCWC |            |&lt;br /&gt;|*  6 |       TABLE ACCESS FULL| VERY_LARGE_FACT_TABLE |    87M|  2176M| 40148   (1)| 00:08:02 |  Q1,00 | PCWP |            |&lt;br /&gt;-----------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;  6 - access(:Z&amp;gt;=:Z AND :Z&amp;lt;=:Z)  &lt;br /&gt;Note -----    &lt;br /&gt;- dynamic sampling used for this statement (level=5)    &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;(The "dynamic sampling level 5 is new "automatic" behaviour in 11gR2.  I will talk about that in a later blog post).&lt;br /&gt;Also note that the elapsed time includes time for dynamic sampling -- which is executed as recursive SQL.&lt;br /&gt;&lt;br /&gt;More information about the execution statistics :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select executions, disk_reads, buffer_gets, elapsed_time/1000, px_servers_executions&lt;br /&gt; 2  from v$sqlstats where sql_id = '&amp;amp;myqry'&lt;br /&gt; 3  /&lt;br /&gt;Enter value for myqry: 8madvr3cvp929&lt;br /&gt;old   2: from v$sqlstats where sql_id = '&amp;amp;myqry'&lt;br /&gt;new   2: from v$sqlstats where sql_id = '8madvr3cvp929'&lt;br /&gt;&lt;br /&gt;EXECUTIONS DISK_READS BUFFER_GETS ELAPSED_TIME/1000 PX_SERVERS_EXECUTIONS&lt;br /&gt;---------- ---------- ----------- ----------------- ---------------------&lt;br /&gt;        1     530326      530607        277849.818                     4&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Conclusive evidence that the query actually used 4 PQ slaves.  There is no PARALLEL Hint in the query but a Parallel DEGREE of 4 has been defined on the table.&lt;br /&gt;&lt;br /&gt;The table is about 4GB in size :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select blocks from user_tables where table_name = 'VERY_LARGE_FACT_TABLE';&lt;br /&gt;&lt;br /&gt;   BLOCKS&lt;br /&gt;----------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select blocks from user_segments where segment_name = 'VERY_LARGE_FACT_TABLE';&lt;br /&gt;&lt;br /&gt;   BLOCKS&lt;br /&gt;----------&lt;br /&gt;   533504&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&gt; select table_name, degree from user_tables    &lt;br /&gt;  2  where table_name = 'VERY_LARGE_FACT_TABLE';&lt;br /&gt;&lt;br /&gt;TABLE_NAME                     DEGREE&lt;br /&gt;------------------------------ ----------------------------------------&lt;br /&gt;VERY_LARGE_FACT_TABLE                   4&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So, the Buffer Gets and Physical Reads statistics (530thousand) reported by AWR are for the SQL but the Total Elapsed Time is the summation of time for the 4 PQ slaves !&lt;br /&gt;Here are some statistics from the AWR :&lt;br /&gt;&lt;pre&gt;Statistic                                     Total&lt;br /&gt;-------------------------------- ------------------&lt;br /&gt;consistent gets                             539,810&lt;br /&gt;consistent gets direct                      530,138&lt;br /&gt;physical read IO requests                     4,747&lt;br /&gt;physical read bytes                   4,348,256,256&lt;br /&gt;physical read total IO requests               5,008&lt;br /&gt;physical read total bytes             4,352,385,024&lt;br /&gt;physical read total multi block               4,190&lt;br /&gt;physical reads                              530,793&lt;br /&gt;physical reads direct                       530,138&lt;br /&gt;table scan blocks gotten                    530,228&lt;br /&gt;table scan rows gotten                   80,010,539&lt;br /&gt;PX local messages recv'd                        120&lt;br /&gt;PX local messages sent                          120&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;About 530thousand table blocks holding 80million rows were fetched using 4thousand multi block read calls to read 4GB.  Those multiblock read calls were made by PX operators (what I call PQ slaves).&lt;br /&gt;&lt;br /&gt;Therefore, although the AWR statistics about I/O by the SQL are correct, the information about elapsed time is wrong ! &lt;br /&gt;&lt;br /&gt;The next time you look at Elapsed Time for a query in an AWR report, you might want to confirm if the query did or did not use Parallel Slaves !&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-59442491170508722?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/59442491170508722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=59442491170508722' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/59442491170508722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/59442491170508722'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/08/reading-awr-2.html' title='Reading an AWR  -- 2'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-404988713370521534</id><published>2011-08-07T12:15:00.011+08:00</published><updated>2011-08-07T15:01:14.593+08:00</updated><title type='text'>Oracle 11g RAC Essentials</title><content type='html'>&lt;a href="http://www.packtpub.com/"&gt;PACKT Publishing&lt;/a&gt; had invited me to review the new 11g RAC book "&lt;a href="http://www.packtpub.com/oracle-11g-r1-r2-real-application-clusters-essentials/book"&gt;Oracle 11g R1/R2 Real Application Clusters Essentials&lt;/a&gt;".  This book, published in May 2011, is an update on the earlier book "Oracle 11g R1/R2 Real Application Clusters Handbook" published in June 2010.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The RAC Clusters Essentials book has been co-authored by &lt;a href="http://oracle-magician.blogspot.com/"&gt;Ben Prusinski&lt;/a&gt; and &lt;a href="http://jaffardba.blogspot.com/"&gt;Syed Jaffer Hussain&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The reader needs to have familiarity with Oracle Database Administration (and, possibly, installation).  However, knowledge of 10gRAC and ASM is not a pre-requisite.  That is refreshing.  If you already know 10g RAC or 11gR1 or 11gR1 RAC, you would appreciate the "New Features" listings for 11gR1 and 11gR2 that are included in each chapter. However, if you are beginning with, say, 9i knowledge, do not fear.  This books brings you up to the right knowledge level.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I like the fact that the book begins with a review of the concept of High Availability.  It doesn't jump into Oracle RAC but sets the stage by having the reader understand and appreciate downtime, the concept of 5 nines, business continuity and recoverability and the available options.  Many DBAs and IT Management may not understand why Oracle seems to have different products (DataGuard, Streams, GoldenGate and RAC).  Each of these is conceptually different and meets a different requirement.  These are introduced here and covered again in Chapter 12.  (The Scalability aspect of RAC comes in Chapter 6 on Workload Management).  {&lt;i&gt;However, I would disagree with the wording in a description of how Oracle handles transaction errors because it uses the phrase 'database recovery'  to describe a rollback followed by a roll-forward.  That section needs a review and rewrite to explain the differences between rollback of failed statements and transactions and database (system) recovery.&lt;/i&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 2 is an overview of RAC architecture. I applaud the inclusion of descriptions of OS and hardware details (although Storage Management applies to non-RAC implementations as well).  Given the level of detail on storage protocols a differentiation between SAN and NAS would have been in order.&lt;/div&gt;&lt;div&gt;It also then goes on to provide brief, introductory, explanations to RAC processes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 3 is a walk-through on the Installation of the Grid and the RAC database.  It very well differentiates between 11gR1 and 11gR2  Grid installations.  The authors have included explanations of what happens when the root scripts are executed and also how to execute post installation checks.&lt;/div&gt;&lt;div&gt;Curiously, the creation of the "grid"  Linux account is a missing step.   The authors have used "oracle" to install the Grid Infrastructure. The documentation allows for "oracle" to own the Grid Infrastructure (particularly in a Typical Installation) but my preference would have been to clearly use "grid" as a separate account for the G.I.    Note that multicasting on the private interconnect are mandatory from 11.2.0.2.  This may need getting the Network team to modify router configuration.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 4 is an overview of ASM.  As I have pointed out earlier, if you have not administered an ASM install in 10g, this chapter helpfully begins with the "basics" -- even though it quickly goes into 11gR1/11gR2 commands.  It also goes on to cover ACFS.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 5 is on managing and troubleshooting Clusterware.  Beginning with descriptions of Clusterware processes, it  goes on to cover the diagnostic commands.  I am impressed by the content in this chapter.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 6 is focussed on the RAC database.  DBAs not familiar with 11g would find the section on ADR useful as well. In my opinion, Services, TAF, FCF and FAN could have been a separate chapter so as to provide more details on these hard-to-understand features.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 7 is on Backup and Recovery.  It also goes on to describe Instance Recovery in RAC.  This I appreciate for it's inclusion.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 8 is on Performance Tuning.  As with Backup and Recovery, it is also an introduction to 11g features for 10g non-RAC DBAs.  I am happy to find that the manner in which 11g features are introduced is consistent throughout the book.  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 9 on Clusterware Upgrades is for existing 10g/11g RAC DBAs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 10, called "Real-world Scenarios"  discusses adding and removing nodes and instances, relocating database instances and converting single-instance databases to RAC.  DBAs need to practice these scenarios so this chapter well placed and provides adequate detail.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 11 is specific to EBusiness Suite implementations.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chapter 12 called "High Availability" provides descriptions of Streams, GoldenGate and DataGuard.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;All in all, I rate the book a 7.5 on 10.  I am impressed by the content.  The book is useful for all DBAs : From those running non-RAC 9i to those already running 11gRAC databases.&lt;/div&gt;&lt;div&gt;I would not hesitate recommending this book to anyone who wants "a good back on Oracle Clusterware and/or RAC".  Even as we notice as in recent Oracle University Courses, Clusterware and RAC are separate topics.  The book handles them appropriately.&lt;/div&gt;&lt;div&gt;I would have liked to see more coverage of RAC One Node and Oracle Restart as well -- possibly as a Chapter 13.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;DISCLOSURE :  Although PACKT Publishing sent me a soft-copy of the book for the review, I am not being paid to write or publish the review.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-404988713370521534?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/404988713370521534/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=404988713370521534' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/404988713370521534'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/404988713370521534'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/08/oracle-11g-rac-essentials.html' title='Oracle 11g RAC Essentials'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4605142065933175487</id><published>2011-07-30T23:11:00.002+08:00</published><updated>2011-07-30T23:19:32.916+08:00</updated><title type='text'>More on COUNT()s -- 2</title><content type='html'>Continuing with my previous posts "&lt;a href="http://hemantoracledba.blogspot.com/2011/07/running-countcolumn-versus-count.html"&gt;Running a COUNT(Column) versus COUNT(*)&lt;/a&gt;" and"&lt;a href="http://hemantoracledba.blogspot.com/2011/07/more-on-counts.html"&gt;More on COUNT()s&lt;/a&gt;", I now go on to demonstrate some more "twists" :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&gt; drop table COUNT_ROWS_TBL ;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&gt; create table COUNT_ROWS_TBL (Column_1 number, Column_2 number, Column_3 varchar2(100)) ;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into COUNT_ROWS_TBL&lt;br /&gt;  2  select decode(mod(rownum,10),0,NULL,rownum) as Column_1,&lt;br /&gt;  3         rownum as Column_2,&lt;br /&gt;  4         'Column_3_Values' || dbms_random.string('X',80) as Column_3&lt;br /&gt;  5  from dual&lt;br /&gt;  6  connect by level &lt; 1001&lt;br /&gt;  7  /&lt;br /&gt;&lt;br /&gt;1000 rows created.&lt;br /&gt;&lt;br /&gt;SQL&gt; -- remember that Column_2 has values 1 to 1000 and has no NULLs&lt;br /&gt;SQL&gt; -- note how count(Column_1) excludes rows with a NULL&lt;br /&gt;SQL&gt; select count(Column_2) from COUNT_ROWS_TBL where Column_2 &gt; 400;&lt;br /&gt;&lt;br /&gt;COUNT(COLUMN_2)&lt;br /&gt;---------------&lt;br /&gt;            600&lt;br /&gt;&lt;br /&gt;SQL&gt; select count(Column_1) from COUNT_ROWS_TBL where Column_2 &gt; 400;&lt;br /&gt;&lt;br /&gt;COUNT(COLUMN_1)&lt;br /&gt;---------------&lt;br /&gt;            540&lt;br /&gt;&lt;br /&gt;SQL&gt; -- this is the count of rows that the query for count(Column_1) excludes&lt;br /&gt;SQL&gt; select count(*) from COUNT_ROWS_TBL where Column_2 &gt; 400 and Column_1 is NULL;&lt;br /&gt;&lt;br /&gt;  COUNT(*)&lt;br /&gt;----------&lt;br /&gt;        60&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- Bitmap Index example : If we have a Bitmap index on Column_1&lt;br /&gt;SQL&gt; create bitmap index COUNT_ROWS_TBL_BMP_1 on COUNT_ROWS_TBL(Column_1);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&gt; exec dbms_stats.gather_table_stats('','COUNT_ROWS_TBL',estimate_percent=&gt;100,cascade=&gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&gt; set autotrace on&lt;br /&gt;SQL&gt; select count(Column_1) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(COLUMN_1)&lt;br /&gt;---------------&lt;br /&gt;            900&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Execution Plan&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;Plan hash value: 1724349832&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                     | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;------------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT              |                      |     1 |     4 |     4   (0)| 00:00:01 |&lt;br /&gt;|   1 |  SORT AGGREGATE               |                      |     1 |     4 |            |          |&lt;br /&gt;|   2 |   BITMAP CONVERSION TO ROWIDS |                      |  1000 |  4000 |     4   (0)| 00:00:01 |&lt;br /&gt;|   3 |    BITMAP INDEX FAST FULL SCAN| COUNT_ROWS_TBL_BMP_1 |       |       |            |          |&lt;br /&gt;------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Statistics&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;          1  recursive calls&lt;br /&gt;          0  db block gets&lt;br /&gt;          8  consistent gets&lt;br /&gt;          0  physical reads&lt;br /&gt;          0  redo size&lt;br /&gt;        429  bytes sent via SQL*Net to client&lt;br /&gt;        419  bytes received via SQL*Net from client&lt;br /&gt;          2  SQL*Net roundtrips to/from client&lt;br /&gt;          0  sorts (memory)&lt;br /&gt;          0  sorts (disk)&lt;br /&gt;          1  rows processed&lt;br /&gt;&lt;br /&gt;SQL&gt; select count(*) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;  COUNT(*)&lt;br /&gt;----------&lt;br /&gt;      1000&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Execution Plan&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;Plan hash value: 2301416134&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                     | Name                 | Rows  | Cost (%CPU)| Time     |&lt;br /&gt;----------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT              |                      |     1 |     4   (0)| 00:00:01 |&lt;br /&gt;|   1 |  SORT AGGREGATE               |                      |     1 |            |          |&lt;br /&gt;|   2 |   BITMAP CONVERSION COUNT     |                      |  1000 |     4   (0)| 00:00:01 |&lt;br /&gt;|   3 |    BITMAP INDEX FAST FULL SCAN| COUNT_ROWS_TBL_BMP_1 |       |            |          |&lt;br /&gt;----------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Statistics&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;          1  recursive calls&lt;br /&gt;          0  db block gets&lt;br /&gt;          8  consistent gets&lt;br /&gt;          0  physical reads&lt;br /&gt;          0  redo size&lt;br /&gt;        422  bytes sent via SQL*Net to client&lt;br /&gt;        419  bytes received via SQL*Net from client&lt;br /&gt;          2  SQL*Net roundtrips to/from client&lt;br /&gt;          0  sorts (memory)&lt;br /&gt;          0  sorts (disk)&lt;br /&gt;          1  rows processed&lt;br /&gt;&lt;br /&gt;SQL&gt; -- Now it could use a Bitmap index even if the column contains NULLs !&lt;br /&gt;SQL&gt; -- BUT !  The Count for the column excluded the NULLs ! &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So, we can have a COUNT of the rows returned from the WHERE clause (or all rows of the table if there is no WHERE clause) executed by :&lt;br /&gt;1.  A FULL TABLE SCAN &lt;br /&gt;2.  An INDEX [FAST] FULL SCAN &lt;br /&gt;3.  A BITMAP Index&lt;br /&gt;&lt;br /&gt;In any case, if you specify a Column as your COUNT target and the Column does contain a NULL in one or more rows, the rows with the NULL are excluded.&lt;br /&gt;On the other hand, if you specify a constaint (e.g. a "1") or a * as your COUNT target, no rows are excluded (other than rows that may have been excluded by filters specified in the WHERE clause).&lt;br /&gt;&lt;br /&gt;Notice how I have NOT demonstrated a Primary Key index (or a Unique Index) being used for a Count.  It is not necessary for an Index to be a Primary Key index for it to be usable by Oracle for this purpose.  There are a number of Internet posts that suggest that Oracle can use a Primary Key to execute a count.  The truth of the matter is that Oracle can use any Index if the index contains elements that are NOT NULL   *OR*  it can use a Bitmap Index because a Bitmap Index also captures NULLs.&lt;br /&gt;&lt;br /&gt;Would anyone want to extent the test case to an Index Organized Table (an IOT)  ?&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4605142065933175487?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4605142065933175487/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4605142065933175487' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4605142065933175487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4605142065933175487'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/more-on-counts-2.html' title='More on COUNT()s -- 2'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-3699601508442321881</id><published>2011-07-29T23:30:00.004+08:00</published><updated>2011-08-01T23:41:35.725+08:00</updated><title type='text'>More on COUNT()s</title><content type='html'>As a followup to my previous post "&lt;a href="http://hemantoracledba.blogspot.com/2011/07/running-countcolumn-versus-count.html"&gt;Running a COUNT(column) versus COUNT(*)&lt;/a&gt;", here's a demo of :&lt;br /&gt;a.  COUNT(column)&lt;br /&gt;b.  COUNT(constant)&lt;br /&gt;c.  COUNT(*)&lt;br /&gt;d. COUNT(*) done via an Index&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; -- Create a test table with 3 columns&lt;br /&gt;SQL&amp;gt; -- The first column happens to have a NULL value for every 10th row&lt;br /&gt;SQL&amp;gt; -- Column_2 contains numbers, all greater than 0&lt;br /&gt;SQL&amp;gt; -- so a query for "WHERE Column_2 &amp;gt; 0" retrieves ALL the rows&lt;br /&gt;SQL&amp;gt; -- Column_3 contains a string&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; create table COUNT_ROWS_TBL (Column_1 number, Column_2 number, Column_3 varchar2(100)) ;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into COUNT_ROWS_TBL&lt;br /&gt;2  select decode(mod(rownum,10),0,NULL,rownum) as Column_1,&lt;br /&gt;3         rownum as Column_2,&lt;br /&gt;4         'Column_3_Values' || dbms_random.string('X',80) as Column_3&lt;br /&gt;5  from dual&lt;br /&gt;6  connect by level &amp;lt; 1001 &lt;br /&gt;7  /&lt;br /&gt;&lt;br /&gt;1000 rows created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- the table has 1000 rows, as evidenced by the output above&lt;br /&gt;SQL&amp;gt; -- verify this :&lt;br /&gt;SQL&amp;gt; select count(*) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(*)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- First example : COUNT(column) doesn't count all the rows&lt;br /&gt;SQL&amp;gt; --   if the column has a NULL in one or more rows&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- note how count(Column_1) excludes rows with a NULL&lt;br /&gt;SQL&amp;gt; select count(Column_1) from COUNT_ROWS_TBL ;&lt;br /&gt;&lt;br /&gt;COUNT(COLUMN_1)&lt;br /&gt;---------------&lt;br /&gt;        900&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(Column_1) from COUNT_ROWS_TBL where Column_2 &amp;gt; 0;&lt;br /&gt;&lt;br /&gt;COUNT(COLUMN_1)&lt;br /&gt;---------------&lt;br /&gt;        900&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- this is the count of rows that the query for count(Column_1) excludes&lt;br /&gt;SQL&amp;gt; select count(*) from COUNT_ROWS_TBL where Column_1 is NULL;&lt;br /&gt;&lt;br /&gt;COUNT(*)&lt;br /&gt;----------&lt;br /&gt;   100&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(Column_2) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(COLUMN_2)&lt;br /&gt;---------------&lt;br /&gt;       1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(Column_2) from COUNT_ROWS_TBL where Column_2 &amp;gt; 0;&lt;br /&gt;&lt;br /&gt;COUNT(COLUMN_2)&lt;br /&gt;---------------&lt;br /&gt;       1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(Column_3) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(COLUMN_3)&lt;br /&gt;---------------&lt;br /&gt;       1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(Column_3) from COUNT_ROWS_TBL where Column_2 &amp;gt; 0;&lt;br /&gt;&lt;br /&gt;COUNT(COLUMN_3)&lt;br /&gt;---------------&lt;br /&gt;       1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- Second example : COUNT(1) does count all the rows&lt;br /&gt;SQL&amp;gt; --    because 1 is a constant, not-NULL, value&lt;br /&gt;SQL&amp;gt; select count(1) from COUNT_ROWS_TBL ;&lt;br /&gt;&lt;br /&gt;COUNT(1)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(1) from COUNT_ROWS_TBL where Column_2 &amp;gt; 0;&lt;br /&gt;&lt;br /&gt;COUNT(1)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(1) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(1)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(1) from COUNT_ROWS_TBL where Column_2 &amp;gt; 0;&lt;br /&gt;&lt;br /&gt;COUNT(1)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(1) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(1)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(1) from COUNT_ROWS_TBL where Column_2 &amp;gt; 0;&lt;br /&gt;&lt;br /&gt;COUNT(1)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- Third example : COUNT(*) might use an Index&lt;br /&gt;SQL&amp;gt; -- If the index is on a column that is guaranteed to not contain NULLs&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; set autotrace on&lt;br /&gt;SQL&amp;gt; select count(*) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(*)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Execution Plan&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;Plan hash value: 3695206450&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation          | Name           | Rows  | Cost (%CPU)| Time     |&lt;br /&gt;-----------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT   |                |     1 |     7   (0)| 00:00:01 |&lt;br /&gt;|   1 |  SORT AGGREGATE    |                |     1 |            |          |&lt;br /&gt;|   2 |   TABLE ACCESS FULL| COUNT_ROWS_TBL |  1000 |     7   (0)| 00:00:01 |&lt;br /&gt;-----------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Note&lt;br /&gt;-----&lt;br /&gt;- dynamic sampling used for this statement (level=2)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Statistics&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;      0  recursive calls&lt;br /&gt;      0  db block gets&lt;br /&gt;     23  consistent gets&lt;br /&gt;      0  physical reads&lt;br /&gt;      0  redo size&lt;br /&gt;    422  bytes sent via SQL*Net to client&lt;br /&gt;    419  bytes received via SQL*Net from client&lt;br /&gt;      2  SQL*Net roundtrips to/from client&lt;br /&gt;      0  sorts (memory)&lt;br /&gt;      0  sorts (disk)&lt;br /&gt;      1  rows processed&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; exec dbms_stats.gather_table_stats('','COUNT_ROWS_TBL',estimate_percent=&amp;gt;100,cascade=&amp;gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select count(*) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(*)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Execution Plan&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;Plan hash value: 3695206450&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation          | Name           | Rows  | Cost (%CPU)| Time     |&lt;br /&gt;-----------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT   |                |     1 |     7   (0)| 00:00:01 |&lt;br /&gt;|   1 |  SORT AGGREGATE    |                |     1 |            |          |&lt;br /&gt;|   2 |   TABLE ACCESS FULL| COUNT_ROWS_TBL |  1000 |     7   (0)| 00:00:01 |&lt;br /&gt;-----------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Statistics&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;      0  recursive calls&lt;br /&gt;      0  db block gets&lt;br /&gt;     23  consistent gets&lt;br /&gt;      0  physical reads&lt;br /&gt;      0  redo size&lt;br /&gt;    422  bytes sent via SQL*Net to client&lt;br /&gt;    419  bytes received via SQL*Net from client&lt;br /&gt;      2  SQL*Net roundtrips to/from client&lt;br /&gt;      0  sorts (memory)&lt;br /&gt;      0  sorts (disk)&lt;br /&gt;      1  rows processed&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; alter table COUNT_ROWS_TBL modify (Column_2 NOT NULL);&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create index COUNT_ROWS_TBL_NDX on COUNT_ROWS_TBL(Column_2);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- NOW ! the Index will be used !&lt;br /&gt;SQL&amp;gt; select count(*) from COUNT_ROWS_TBL;&lt;br /&gt;&lt;br /&gt;COUNT(*)&lt;br /&gt;----------&lt;br /&gt;  1000&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Execution Plan&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;Plan hash value: 1131752359&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation             | Name               | Rows  | Cost (%CPU)| Time     |&lt;br /&gt;------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT      |                    |     1 |     3   (0)| 00:00:01 |&lt;br /&gt;|   1 |  SORT AGGREGATE       |                    |     1 |            |          |&lt;br /&gt;|   2 |   INDEX FAST FULL SCAN| COUNT_ROWS_TBL_NDX |  1000 |     3   (0)| 00:00:01 |&lt;br /&gt;------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Statistics&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;      1  recursive calls&lt;br /&gt;      0  db block gets&lt;br /&gt;      7  consistent gets&lt;br /&gt;      3  physical reads&lt;br /&gt;      0  redo size&lt;br /&gt;    422  bytes sent via SQL*Net to client&lt;br /&gt;    419  bytes received via SQL*Net from client&lt;br /&gt;      2  SQL*Net roundtrips to/from client&lt;br /&gt;      0  sorts (memory)&lt;br /&gt;      0  sorts (disk)&lt;br /&gt;      1  rows processed&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; -- note how Oracle chose to use the Index now&lt;br /&gt;SQL&amp;gt; -- Remember : It will use the Index IF :&lt;br /&gt;SQL&amp;gt; --- a.     The Indexed Column&lt;br /&gt;SQL&amp;gt;       (or at least one column in a composite index)&lt;br /&gt;2        is a NOT NULL column&lt;br /&gt;3  --- b.     The calculated "Cost" (determined by the Query optimizer)&lt;br /&gt;4  ---   is lower for an Index [Fast] Full Scan than for a Full Table Scan&lt;br /&gt;5&lt;br /&gt;SQL&amp;gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So, a COUNT(column) and a COUNT(constant) and a COUNT(*) do not necessarily mean the same thing.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;UPDATE :&lt;/div&gt;&lt;div&gt;See the subsequent post&lt;/div&gt;&lt;div&gt;&lt;a href="http://hemantoracledba.blogspot.com/2011/07/more-on-counts-2.html"&gt;More on COUNT()s  -- 2&lt;/a&gt;&lt;/div&gt;&lt;div&gt;.&lt;br /&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-3699601508442321881?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/3699601508442321881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=3699601508442321881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3699601508442321881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3699601508442321881'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/more-on-counts.html' title='More on COUNT()s'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-3898525408549256779</id><published>2011-07-27T11:56:00.001+08:00</published><updated>2011-07-27T11:57:46.318+08:00</updated><title type='text'>Data Quality Issues cannot always be addressed by programming</title><content type='html'>Here's an example of a data quality issue that SQL , PLSQL, Oracle Text etc cannot resolve for you :&lt;br /&gt;&lt;br /&gt;&lt;a href="http://forums.oracle.com/forums/thread.jspa?threadID=2259111&amp;amp;tstart=0"&gt;http://forums.oracle.com/forums/thread.jspa?threadID=2259111&amp;amp;tstart=0&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;See my comments in the thread.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-3898525408549256779?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/3898525408549256779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=3898525408549256779' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3898525408549256779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3898525408549256779'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/data-quality-issues-cannot-always-be.html' title='Data Quality Issues cannot always be addressed by programming'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-5180084288001881419</id><published>2011-07-25T17:17:00.002+08:00</published><updated>2011-08-01T23:40:43.003+08:00</updated><title type='text'>Running a COUNT(column) versus COUNT(*)</title><content type='html'>Just a quick post about the recurring myths about COUNT operations in Oracle.&lt;br /&gt;See the discussion in &lt;a href="http://forums.oracle.com/forums/thread.jspa?threadID=2257942&amp;amp;tstart=0"&gt;this forums thread&lt;/a&gt;.&lt;br /&gt;.&lt;br /&gt;UPDATE : Also see these two subsequent posts :&lt;div&gt;&lt;a href="http://hemantoracledba.blogspot.com/2011/07/more-on-counts.html"&gt;More on COUNT()s&lt;/a&gt;&lt;/div&gt;&lt;div&gt;and &lt;/div&gt;&lt;div&gt;&lt;a href="http://hemantoracledba.blogspot.com/2011/07/more-on-counts-2.html"&gt;More on COUNT()s -- 2&lt;/a&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-5180084288001881419?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/5180084288001881419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=5180084288001881419' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5180084288001881419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5180084288001881419'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/running-countcolumn-versus-count.html' title='Running a COUNT(column) versus COUNT(*)'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4616422685122627273</id><published>2011-07-20T23:01:00.006+08:00</published><updated>2011-07-20T23:11:54.408+08:00</updated><title type='text'>Oracle Database "Performance" - A Diagnostics Method</title><content type='html'>I have just completed a Webinar at &lt;a href="http://www.brainsurface.com/virtathon"&gt;BrainSurface Virtathon&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I have uploaded a copy of the presentation '&lt;a href="https://sites.google.com/site/hemantswebsite/oracle-diagnostics/Oracle_Database_Performance_Diagnostics.pdf"&gt;Oracle Database "Performance" - A Diagnostics Approach&lt;/a&gt;' at my "&lt;a href="https://sites.google.com/site/hemantswebsite/oracle-diagnostics"&gt;Oracle Diagnostics Presentations&lt;/a&gt;" site.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4616422685122627273?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4616422685122627273/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4616422685122627273' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4616422685122627273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4616422685122627273'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/oracle-database-performance-diagnostics.html' title='Oracle Database &quot;Performance&quot; - A Diagnostics Method'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-8567236644924994006</id><published>2011-07-13T22:37:00.002+08:00</published><updated>2011-07-13T22:54:31.464+08:00</updated><title type='text'>ENABLE ROW MOVEMENT with MSSM</title><content type='html'>As I demonstrated in my previous blog post "&lt;a href="http://hemantoracledba.blogspot.com/2011/07/enable-row-movement.html"&gt;ENABLE ROW MOVEMENT&lt;/a&gt;"   the ALTER TABLE ... ENABLE ROW MOVEMENT is not just for supporting the ALTER TABLE ... SHRINK SPACE.&lt;br /&gt;&lt;br /&gt;Furthermore, unlike ALTER TABLE ... SHRINK SPACE which requires that the Table be created in a Tablespace with Segment Space Management AUTO ("ASSM"),  ENABLE ROW MOVEMENT can be done for a table in a Segment Space Management MANUAL ("MSSM") Tablespace as well.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&gt; create tablespace MSSM&lt;br /&gt;  2  datafile '/addtl/oracle/oradata/orcl/MSSM.dbf' size 100M&lt;br /&gt;  3  extent management local segment space management manual&lt;br /&gt;  4  /&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- create a "normal" partitoned table&lt;br /&gt;SQL&gt; --  this time create it in an MSSM tablespace&lt;br /&gt;SQL&gt; drop table my_emp_tbl purge;&lt;br /&gt;drop table my_emp_tbl purge&lt;br /&gt;           *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00942: table or view does not exist&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; create table my_emp_tbl&lt;br /&gt;  2  (emp_id   number not null primary key,&lt;br /&gt;  3   country_id  varchar2(2),&lt;br /&gt;  4   emp_name varchar2(50),&lt;br /&gt;  5   join_date date)&lt;br /&gt;  6  partition by list (country_id)&lt;br /&gt;  7  (&lt;br /&gt;  8  partition my_emp_tbl_in values ('IN'),&lt;br /&gt;  9  partition my_emp_tbl_sg values ('SG'),&lt;br /&gt; 10  partition my_emp_tbl_us values ('US')&lt;br /&gt; 11  )&lt;br /&gt; 12  tablespace MSSM&lt;br /&gt; 13  /&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; select partition_name, tablespace_name&lt;br /&gt;  2  from user_tab_partitions&lt;br /&gt;  3  where table_name = 'MY_EMP_TBL'&lt;br /&gt;  4  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                 TABLESPACE_NAME&lt;br /&gt;------------------------------ ------------------------------&lt;br /&gt;MY_EMP_TBL_IN                  MSSM&lt;br /&gt;MY_EMP_TBL_SG                  MSSM&lt;br /&gt;MY_EMP_TBL_US                  MSSM&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; insert into my_emp_tbl&lt;br /&gt;  2  select rownum,&lt;br /&gt;  3  decode(mod(rownum,3),0,'IN',1,'SG',2,'US'),&lt;br /&gt;  4  dbms_random.string('X',40),&lt;br /&gt;  5  sysdate-365+rownum&lt;br /&gt;  6  from dual connect by level &lt; 100&lt;br /&gt;  7  /&lt;br /&gt;&lt;br /&gt;99 rows created.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- collect statistics on row counts&lt;br /&gt;SQL&gt; exec dbms_stats.gather_table_stats('','MY_EMP_TBL',estimate_percent=&gt;100,granularity=&gt;'ALL');&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&gt; select partition_name, num_rows&lt;br /&gt;  2  from user_tab_partitions&lt;br /&gt;  3  where table_name = 'MY_EMP_TBL'&lt;br /&gt;  4  order by partition_position&lt;br /&gt;  5  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                   NUM_ROWS&lt;br /&gt;------------------------------ ----------&lt;br /&gt;MY_EMP_TBL_IN                          33&lt;br /&gt;MY_EMP_TBL_SG                          33&lt;br /&gt;MY_EMP_TBL_US                          33&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- identify employee 4&lt;br /&gt;SQL&gt; select * from my_emp_tbl where emp_id = 4;&lt;br /&gt;&lt;br /&gt;    EMP_ID CO EMP_NAME&lt;br /&gt;---------- -- --------------------------------------------------&lt;br /&gt;JOIN_DATE&lt;br /&gt;---------&lt;br /&gt;         4 SG WS46VU0RIJDKOIXXAZSEPWUIVG0QBHTL4FUBNYPY&lt;br /&gt;17-JUL-10&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; -- change the employees country&lt;br /&gt;SQL&gt; update my_emp_tbl set country_id = 'IN' where emp_id = 4;&lt;br /&gt;update my_emp_tbl set country_id = 'IN' where emp_id = 4&lt;br /&gt;       *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-14402: updating partition key column would cause a partition change&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- enable row movement&lt;br /&gt;SQL&gt; alter table my_emp_tbl enable row movement;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; update my_emp_tbl set country_id = 'IN' where emp_id = 4;&lt;br /&gt;&lt;br /&gt;1 row updated.&lt;br /&gt;&lt;br /&gt;SQL&gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I know for a fact that ALTER TABLE ... ENABLE ROW MOVEMENT appears in the 8i documentation --- predating ASSM Tablespaces.&lt;br /&gt;&lt;br /&gt;Thus, ALTER TABLE ... ENABLE ROW MOVEMENT is independent of and significantly predates ALTER TABLE ... SHRINK.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-8567236644924994006?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/8567236644924994006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=8567236644924994006' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/8567236644924994006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/8567236644924994006'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/enable-row-movement-with-mssm.html' title='ENABLE ROW MOVEMENT with MSSM'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4076096266001545727</id><published>2011-07-13T11:18:00.002+08:00</published><updated>2011-07-13T11:19:23.497+08:00</updated><title type='text'>Virtathon Sessions Schedule</title><content type='html'>The Sessions Schedule for Virtathon has been published.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.brainsurface.com/virtathon/sessions-schedule"&gt;View it here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;(note : The published session times are US EDT (GMT -4))&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4076096266001545727?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4076096266001545727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4076096266001545727' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4076096266001545727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4076096266001545727'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/virtathon-sessions-schedule.html' title='Virtathon Sessions Schedule'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7896510565515381723</id><published>2011-07-12T22:50:00.002+08:00</published><updated>2011-07-12T22:57:04.092+08:00</updated><title type='text'>ENABLE ROW MOVEMENT</title><content type='html'>Since the ALTER TABLE SHRINK command appeared and "ENABLE ROW MOVEMENT" has been presented as a requirement, some DBAs have been confused about what it means to enable row movement.&lt;br /&gt;&lt;br /&gt;This does *NOT* cause Oracle to automatically move a row.  However, a row may be moved as a result of action by the DBA  (e.g. ALTER TABLE SHRINK) or a User / Application.  The latter is the case where a row in a Partitioned Table has to move from one Partition to another because the Partition Key itself in that row has been updated.&lt;br /&gt;Note that updating the Partition Key (such that a row actually moves to another Partition)  is frowned upon and is not enabled by default.  In the rare case where your design has a flaw that rows have to move between Partitions, you need to ENABLE ROW MOVEMENT.&lt;br /&gt;&lt;br /&gt;In the example below, a row has to move from the 'SG' Partition to the 'IN' Partition.  This is disallowed by Oracle until and unless the DBA ENABLEs ROW MOVEMENT :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&gt; -- create a "normal" partitoned table&lt;br /&gt;SQL&gt; drop table my_emp_tbl purge;&lt;br /&gt;&lt;br /&gt;Table dropped.&lt;br /&gt;&lt;br /&gt;SQL&gt; create table my_emp_tbl&lt;br /&gt;  2  (emp_id   number not null primary key,&lt;br /&gt;  3   country_id  varchar2(2),&lt;br /&gt;  4   emp_name varchar2(50),&lt;br /&gt;  5   join_date date)&lt;br /&gt;  6  partition by list (country_id)&lt;br /&gt;  7  (&lt;br /&gt;  8  partition my_emp_tbl_in values ('IN'),&lt;br /&gt;  9  partition my_emp_tbl_sg values ('SG'),&lt;br /&gt; 10  partition my_emp_tbl_us values ('US')&lt;br /&gt; 11  )&lt;br /&gt; 12  /&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; insert into my_emp_tbl&lt;br /&gt;  2  select rownum,&lt;br /&gt;  3  decode(mod(rownum,3),0,'IN',1,'SG',2,'US'),&lt;br /&gt;  4  dbms_random.string('X',40),&lt;br /&gt;  5  sysdate-365+rownum&lt;br /&gt;  6  from dual connect by level &lt; 100&lt;br /&gt;  7  /&lt;br /&gt;&lt;br /&gt;99 rows created.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- collect statistics on row counts&lt;br /&gt;SQL&gt; exec dbms_stats.gather_table_stats('','MY_EMP_TBL',estimate_percent=&gt;100,granularity=&gt;'ALL');&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&gt; select partition_name, num_rows&lt;br /&gt;  2  from user_tab_partitions&lt;br /&gt;  3  where table_name = 'MY_EMP_TBL'&lt;br /&gt;  4  order by partition_position&lt;br /&gt;  5  /&lt;br /&gt;&lt;br /&gt;PARTITION_NAME                   NUM_ROWS&lt;br /&gt;------------------------------ ----------&lt;br /&gt;MY_EMP_TBL_IN                          33&lt;br /&gt;MY_EMP_TBL_SG                          33&lt;br /&gt;MY_EMP_TBL_US                          33&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- identify employee 4&lt;br /&gt;SQL&gt; select * from my_emp_tbl where emp_id = 4;&lt;br /&gt;&lt;br /&gt;    EMP_ID CO EMP_NAME&lt;br /&gt;---------- -- --------------------------------------------------&lt;br /&gt;JOIN_DATE&lt;br /&gt;---------&lt;br /&gt;         4 SG 9WSXMYH66V6I8B1LKKW7YRTG2VYQGY2OPIT54OFW&lt;br /&gt;16-JUL-10&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; -- change the employees country&lt;br /&gt;SQL&gt; update my_emp_tbl set country_id = 'IN' where emp_id = 4;&lt;br /&gt;update my_emp_tbl set country_id = 'IN' where emp_id = 4&lt;br /&gt;       *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-14402: updating partition key column would cause a partition change&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; -- enable row movement&lt;br /&gt;SQL&gt; alter table my_emp_tbl enable row movement;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; update my_emp_tbl set country_id = 'IN' where emp_id = 4;&lt;br /&gt;&lt;br /&gt;1 row updated.&lt;br /&gt;&lt;br /&gt;SQL&gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So it is not just ALTER TABLE SHRINK that the ENABLE ROW MOVEMENT is necessary for.  Yet, it is likely a defect in your design if you have frequent movements of rows between Partitions.  Remember that GLOBAL and LOCAL Indexes have to be updated.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7896510565515381723?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7896510565515381723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7896510565515381723' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7896510565515381723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7896510565515381723'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/enable-row-movement.html' title='ENABLE ROW MOVEMENT'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-3479619135897990921</id><published>2011-07-12T14:59:00.002+08:00</published><updated>2011-07-12T15:01:13.418+08:00</updated><title type='text'>Using WGET to download Patches</title><content type='html'>(more of a "public bookmark" here, because it's been a long time since I downloaded a patch)&lt;br /&gt;&lt;br /&gt;Oracle Support's update on using WGET to download patches is &lt;a href="http://blogs.oracle.com/supportportal/entry/use_of_wget_instead_of_downloa"&gt;in their blog&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-3479619135897990921?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/3479619135897990921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=3479619135897990921' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3479619135897990921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3479619135897990921'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/using-wget-to-download-patches.html' title='Using WGET to download Patches'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-4610764231396021691</id><published>2011-07-09T12:38:00.003+08:00</published><updated>2011-07-16T23:25:10.208+08:00</updated><title type='text'>Reading an AWR - 1</title><content type='html'>Given this extract from an AWR :&lt;br /&gt;&lt;pre&gt;Instance Efficiency Percentages (Target 100%)&lt;br /&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;          Buffer Nowait %:  100.00       Redo NoWait %:  100.00&lt;br /&gt;          Buffer  Hit   %:   99.93    In-memory Sort %:  100.00&lt;br /&gt;          Library Hit   %:   94.76        Soft Parse %:   96.21&lt;br /&gt;       Execute to Parse %:   30.63         Latch Hit %:  100.00&lt;br /&gt;Parse CPU to Parse Elapsd %:   79.13     % Non-Parse CPU:   93.52&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Should I be worried about the Parse ratios ?&lt;br /&gt;&lt;br /&gt;I then look at the "SQL ordered by Parse calls" section :&lt;br /&gt;&lt;pre&gt;-&amp;gt; Total Parse Calls:          24,049&lt;br /&gt;-&amp;gt; Captured SQL account for   71.1% of Total&lt;br /&gt;&lt;br /&gt;                          % Total&lt;br /&gt;Parse Calls  Executions     Parses    SQL Id&lt;br /&gt;------------ ------------ --------- -------------&lt;br /&gt;     5,208        5,208     21.66 bsa0wjtftg3uw&lt;br /&gt;select file# from file$ where ts#=:1&lt;br /&gt;&lt;br /&gt;     3,868        3,868     16.08 cm5vu20fhtnq1&lt;br /&gt;select /*+ connect_by_filtering */ privilege#,level from sysauth$ connect by gra&lt;br /&gt;ntee#=prior privilege# and privilege#&amp;gt;0 start with grantee#=:1 and privilege#&amp;gt;0&lt;br /&gt;&lt;br /&gt;       861          861      3.58 86708bvah4akq&lt;br /&gt;select name from undo$ where file#=:1 and block#=:2 and ts#=:3 and status$&lt;br /&gt;!= 1&lt;br /&gt;&lt;br /&gt;       660          660      2.74 0kkhhb2w93cx0&lt;br /&gt;update seg$ set type#=:4,blocks=:5,extents=:6,minexts=:7,maxexts=:8,extsize=:9,e&lt;br /&gt;xtpct=:10,user#=:11,iniexts=:12,lists=decode(:13, 65535, NULL, :13),groups=decod&lt;br /&gt;e(:14, 65535, NULL, :14), cachehint=:15, hwmincr=:16, spare1=DECODE(:17,0,NULL,:&lt;br /&gt;17),scanhint=:18, bitmapranges=:19 where ts#=:1 and file#=:2 and block#=:3&lt;br /&gt;&lt;br /&gt;       625          440      2.60 0v3dvmc22qnam&lt;br /&gt;insert into sys.col_usage$ (obj#, intcol#, equality_preds, equijoin_preds, noneq&lt;br /&gt;uijoin_preds, range_preds, like_preds, null_preds, timestamp) values ( :objn,&lt;br /&gt;:coln, decode(bitand(:flag,1),0,0,1), decode(bitand(:flag,2),0,0,1), decod&lt;br /&gt;e(bitand(:flag,4),0,0,1), decode(bitand(:flag,8),0,0,1), decode(bitand(:flag&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Should I be worried about the parse calls on SYSAUTH$ ?  What about the lookups on FILE$ that are parsed so many times ?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What do you guys say ?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I'll see what responses I get.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;UPDATE : 16-Jul-11 :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There were 3 responses.&lt;br /&gt;The first was that the "Top 5 timed events" must be checked.  The third response was that the elapsed time and database time must be checked.&lt;br /&gt;&lt;br /&gt;Here they are, with Load Profile included as well :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;              Snap Id      Snap Time      Sessions Curs/Sess&lt;br /&gt;            --------- ------------------- -------- ---------&lt;br /&gt;Begin Snap:      1230 08-Jul-11 21:53:22        26       1.3&lt;br /&gt;  End Snap:      1234 08-Jul-11 23:00:45        32       1.1&lt;br /&gt;   Elapsed:               67.38 (mins)&lt;br /&gt;   DB Time:                3.45 (mins)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Top 5 Timed Foreground Events&lt;br /&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;                                                           Avg&lt;br /&gt;                                                          wait   % DB&lt;br /&gt;Event                                 Waits     Time(s)   (ms)   time Wait Class&lt;br /&gt;------------------------------ ------------ ----------- ------ ------ ----------&lt;br /&gt;DB CPU                                              132          63.7&lt;br /&gt;log buffer space                          9           3    349    1.5 Configurat&lt;br /&gt;enq: CR - block range reuse ck           44           3     69    1.5 Other&lt;br /&gt;log file switch (checkpoint in            2           2   1201    1.2 Configurat&lt;br /&gt;log file switch completion               21           1     47     .5 Configurat&lt;br /&gt;&lt;br /&gt;Host CPU (CPUs:    1 Cores:    1 Sockets:    1)&lt;br /&gt;~~~~~~~~         Load Average&lt;br /&gt;               Begin       End     %User   %System      %WIO     %Idle&lt;br /&gt;           --------- --------- --------- --------- --------- ---------&lt;br /&gt;                0.33      1.32       1.3      17.7       1.5      78.4&lt;br /&gt;&lt;br /&gt;Load Profile              Per Second    Per Transaction   Per Exec   Per Call&lt;br /&gt;~~~~~~~~~~~~         ---------------    --------------- ---------- ----------&lt;br /&gt;      DB Time(s):                0.1                0.4       0.01       0.06&lt;br /&gt;       DB CPU(s):                0.0                0.2       0.00       0.04&lt;br /&gt;       Redo size:          341,639.6        2,539,120.1&lt;br /&gt;   Logical reads:            1,435.2           10,666.3&lt;br /&gt;   Block changes:            1,612.4           11,983.4&lt;br /&gt;  Physical reads:                0.9                7.0&lt;br /&gt; Physical writes:               25.6              190.3&lt;br /&gt;      User calls:                0.9                6.5&lt;br /&gt;          Parses:                6.0               44.2&lt;br /&gt;     Hard parses:                0.2                1.7&lt;br /&gt;W/A MB processed:                0.0                0.3&lt;br /&gt;          Logons:                0.1                0.5&lt;br /&gt;        Executes:                8.6               63.7&lt;br /&gt;       Rollbacks:                0.0                0.0&lt;br /&gt;    Transactions:                0.1&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can see that the there was very little activity in the database. Less than 4 minutes of database time in 67minutes of elapsed time.  There was less than 1 user call per second and 6 parses per second.&lt;br /&gt;So, there was *some* activity occurring (6 parses per second on machine with only 1 CPU/Core). But it didn't consume significant resources.  6 parses per second over 67minutes does account for the more than 24thousand parses.  &lt;br /&gt;&lt;br /&gt;Why the high activity on FILE$ ?  There was a job that was periodically dropping a table, creating a new table, populating it with 400,000 rows, deleting them, doing a rollback and then a count. The job would, in a loop, after a noticeable "sleep" period, run another pass of drop-create-populate-delete-rollback-count.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this case, the data dictionary queries/updates (FILE$, SYSAUTH$, UNDO$, SEG$, COL_USAGE$) were all because of the pattern of operations. (FILE$ to identify the file for the extent allocation,  SEG$ to update the table segment information with each new extent added, SYSAUTH$ for the privileges, UNDO$ for the undo segment and COL_USAGE$ to update column usage on queries.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With respect to the second response about the data dictionary stats and object stats, these were not an issue here.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-4610764231396021691?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/4610764231396021691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=4610764231396021691' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4610764231396021691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/4610764231396021691'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/reading-awr-1.html' title='Reading an AWR - 1'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-1922589725551881663</id><published>2011-07-05T22:57:00.002+08:00</published><updated>2011-07-05T23:23:46.065+08:00</updated><title type='text'>Multiple Channels in RMAN are not always balanced</title><content type='html'>Occasionally, we come across questions about multiple channels and parallelism in RMAN.&lt;br /&gt;Although RMAN distributes the datafiles across the channels, it doesn't necessarily mean that each channel has the same I/O requirements and needs the same amount of time.  One channel may be reading more data and writing a larger backup than another.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For example, in this database with 16 datafiles where data is not equally distributed across all the datafiles :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&gt; select file_id, sum(blocks) from dba_extents group by file_id order by 1;&lt;br /&gt;&lt;br /&gt;   FILE_ID SUM(BLOCKS)&lt;br /&gt;---------- -----------&lt;br /&gt;         1      105632&lt;br /&gt;         2      122320&lt;br /&gt;         3      259880&lt;br /&gt;         4       18864&lt;br /&gt;         5        8952&lt;br /&gt;        13         152&lt;br /&gt;        14       31368&lt;br /&gt;        15        2912&lt;br /&gt;        16        2336&lt;br /&gt;        17           8&lt;br /&gt;&lt;br /&gt;10 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I then run an RMAN backup with two channels :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;RMAN&gt; show device type;&lt;br /&gt;&lt;br /&gt;RMAN configuration parameters for database with db_unique_name ORCL are:&lt;br /&gt;CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;&lt;br /&gt;&lt;br /&gt;RMAN&gt;  &lt;br /&gt;&lt;br /&gt;RMAN&gt; backup as compressed backupset database;&lt;br /&gt;&lt;br /&gt;Starting backup at 05_JUL_23_02_29&lt;br /&gt;allocated channel: ORA_DISK_1&lt;br /&gt;channel ORA_DISK_1: SID=1 device type=DISK&lt;br /&gt;allocated channel: ORA_DISK_2&lt;br /&gt;channel ORA_DISK_2: SID=39 device type=DISK&lt;br /&gt;channel ORA_DISK_1: starting compressed full datafile backup set&lt;br /&gt;channel ORA_DISK_1: specifying datafile(s) in backup set&lt;br /&gt;input datafile file number=00003 name=/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf&lt;br /&gt;input datafile file number=00014 name=/addtl/oracle/oradata/orcl/hemant01.dbf&lt;br /&gt;input datafile file number=00016 name=/addtl/oracle/oradata/orcl/Uniform_64KB.dbf&lt;br /&gt;input datafile file number=00015 name=/addtl/oracle/oradata/orcl/UNDO.dbf&lt;br /&gt;input datafile file number=00017 name=/usr/tmp/X.dbf&lt;br /&gt;input datafile file number=00002 name=/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf&lt;br /&gt;input datafile file number=00001 name=/home/oracle/app/oracle/oradata/orcl/system01.dbf&lt;br /&gt;input datafile file number=00004 name=/home/oracle/app/oracle/oradata/orcl/users01.dbf&lt;br /&gt;input datafile file number=00005 name=/home/oracle/app/oracle/oradata/orcl/example01.dbf&lt;br /&gt;channel ORA_DISK_1: starting piece 1 at 05_JUL_23_02_32&lt;br /&gt;channel ORA_DISK_2: starting compressed full datafile backup set&lt;br /&gt;channel ORA_DISK_2: specifying datafile(s) in backup set&lt;br /&gt;input datafile file number=00006 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1046101119510758.dbf&lt;br /&gt;input datafile file number=00007 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1146416395631714.dbf&lt;br /&gt;input datafile file number=00008 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1170420963682633.dbf&lt;br /&gt;input datafile file number=00009 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1194425963955800.dbf&lt;br /&gt;input datafile file number=00010 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1218408858999342.dbf&lt;br /&gt;input datafile file number=00011 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1242310449730067.dbf&lt;br /&gt;input datafile file number=00012 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1266412439758696.dbf&lt;br /&gt;input datafile file number=00013 name=/home/oracle/app/oracle/oradata/orcl/APEX_1295922881855015.dbf&lt;br /&gt;channel ORA_DISK_2: starting piece 1 at 05_JUL_23_02_33&lt;br /&gt;channel ORA_DISK_2: finished piece 1 at 05_JUL_23_02_40&lt;br /&gt;piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_07_05/o1_mf_nnndf_TAG20110705T230230_7169w9t3_.bkp tag=TAG20110705T230230 comment=NONE&lt;br /&gt;channel ORA_DISK_2: backup set complete, elapsed time: 00:00:07&lt;br /&gt;channel ORA_DISK_1: finished piece 1 at 05_JUL_23_06_40&lt;br /&gt;piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_07_05/o1_mf_nnndf_TAG20110705T230230_7169w8s7_.bkp tag=TAG20110705T230230 comment=NONE&lt;br /&gt;channel ORA_DISK_1: backup set complete, elapsed time: 00:04:08&lt;br /&gt;Finished backup at 05_JUL_23_06_40  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, Channel ORA_DISK_2 did a backup of 8 datafiles in 7seconds while Channel ORA_DISK_1 took 248 seconds to run a backup of 9 datafiles !&lt;br /&gt;&lt;br /&gt;The next time you wonder why one RMAN channel takes a longer time than the other ..... ask yourself if the two channels have been given the same amount of "work" to do.&lt;br /&gt;&lt;br /&gt;In my case, Channel ORA_DISK_2 had to backup data from 152 blocks only but Channel ORA_DISK_1 had to backup data from 551,104 blocks  (*assuming* that there are no "empty" blocks that were formerly part of used extents but are now free extents)  :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&gt; select file_id, sum(blocks) from dba_extents&lt;br /&gt;  2  where file_id in&lt;br /&gt;  3  (select file_id from dba_data_files&lt;br /&gt;  4    where (file_name like '%FLOW%' or file_name like '%APEX%')&lt;br /&gt;  5  )&lt;br /&gt;  6  group by file_id&lt;br /&gt;  7  order by file_id&lt;br /&gt;  8  /&lt;br /&gt;&lt;br /&gt;   FILE_ID SUM(BLOCKS)&lt;br /&gt;---------- -----------&lt;br /&gt;        13         152&lt;br /&gt;           -----------&lt;br /&gt;sum                152&lt;br /&gt;&lt;br /&gt;SQL&gt; select file_id, sum(blocks) from dba_extents&lt;br /&gt;  2  where file_id not in&lt;br /&gt;  3  (select file_id from dba_data_files&lt;br /&gt;  4    where (file_name like '%FLOW%' or file_name like '%APEX%')&lt;br /&gt;  5  )&lt;br /&gt;  6  group by file_id&lt;br /&gt;  7  order by file_id&lt;br /&gt;  8  /&lt;br /&gt;&lt;br /&gt;   FILE_ID SUM(BLOCKS)&lt;br /&gt;---------- -----------&lt;br /&gt;         1      105632&lt;br /&gt;         2      121032&lt;br /&gt;         3      259880&lt;br /&gt;         4       18864&lt;br /&gt;         5        8952&lt;br /&gt;        14       31368&lt;br /&gt;        15        3032&lt;br /&gt;        16        2336&lt;br /&gt;        17           8&lt;br /&gt;           -----------&lt;br /&gt;sum             551104&lt;br /&gt;&lt;br /&gt;9 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&gt; &lt;br /&gt;SQL&gt; select sum(space) from dba_recyclebin;&lt;br /&gt;&lt;br /&gt;SUM(SPACE)&lt;br /&gt;----------&lt;br /&gt;         0&lt;br /&gt;&lt;br /&gt;SQL&gt;   &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : What can you do to address this "imbalance" ?&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-1922589725551881663?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/1922589725551881663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=1922589725551881663' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1922589725551881663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/1922589725551881663'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/07/multiple-channels-in-rman-are-not.html' title='Multiple Channels in RMAN are not always balanced'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-2199611169750905477</id><published>2011-06-28T00:21:00.002+08:00</published><updated>2011-06-28T00:42:07.811+08:00</updated><title type='text'>DDL Triggers</title><content type='html'>A few weeks ago, there was a question about disabling TRUNCATEs.  That can be easily done via a Trigger.  &lt;div&gt;But you have to be careful about such triggers.  Such a trigger can disable a TRUNCATE and raise an error.  It will *not*, however, prevent a COMMIT.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Here's an example of such a trigger :&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SQL&amp;gt; -- create a trigger that raises an error on truncates&lt;br /&gt;SQL&amp;gt; create or replace trigger prevent_truncates&lt;br /&gt; 2  before truncate on schema&lt;br /&gt; 3  begin&lt;br /&gt; 4    raise_application_error(-20001,'TRUNCATE not permitted');&lt;br /&gt; 5  end;&lt;br /&gt; 6  /&lt;br /&gt;&lt;br /&gt;Trigger created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- test the trigger&lt;br /&gt;SQL&amp;gt; create table TEST_TRIG_TBL_1 (primkey number primary key,  data_col varchar2(500));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; truncate table TEST_TRIG_TBL_1;&lt;br /&gt;&lt;br /&gt;truncate table TEST_TRIG_TBL_1&lt;br /&gt;              *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00604: error occurred at recursive SQL level 1&lt;br /&gt;ORA-20001: TRUNCATE not permitted&lt;br /&gt;ORA-06512: at line 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So the trigger works as designed.  It prevents a TRUNCATE in the schema.&lt;br /&gt;&lt;br /&gt;But what if there IS data ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; -- what if there is data ?&lt;br /&gt;SQL&amp;gt; create table TEST_TRIG_TBL_2 (primkey number primary key,  data_col varchar2(500));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into TEST_TRIG_TBL_2 values (1,'ABCDEFGH');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into TEST_TRIG_TBL_2 values (2,'ZXCV');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; truncate table TEST_TRIG_TBL_2;&lt;br /&gt;truncate table TEST_TRIG_TBL_2&lt;br /&gt;              *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00604: error occurred at recursive SQL level 1&lt;br /&gt;ORA-20001: TRUNCATE not permitted&lt;br /&gt;ORA-06512: at line 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- is the data present ?&lt;br /&gt;SQL&amp;gt; select * from TEST_TRIG_TBL_2 ;&lt;br /&gt;&lt;br /&gt;  PRIMKEY&lt;br /&gt;----------&lt;br /&gt;DATA_COL&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;        1&lt;br /&gt;ABCDEFGH&lt;br /&gt;&lt;br /&gt;        2&lt;br /&gt;ZXCV&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The data is present.&lt;br /&gt;&lt;br /&gt;So, is there a COMMIT ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; -- do you realise what this means ?&lt;br /&gt;SQL&amp;gt; -- suppose your transaction consists of more than 2 DML statements&lt;br /&gt;SQL&amp;gt; -- one does an insert into table X and the other attempts to truncate table Y&lt;br /&gt;SQL&amp;gt; -- if the truncate of Y fails, does the insert into X get rolled back ?&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; create table X (primkey number primary key, data_col varchar2(5));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; create table Y (primkey number primary key, data_col varchar2(5));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- insert into X&lt;br /&gt;SQL&amp;gt; insert into X values (1,'QWERT');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into X values (2,'ASDF');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- truncate Y, the developer doesn't know that the TRUNCATE will fail&lt;br /&gt;SQL&amp;gt; truncate table Y;&lt;br /&gt;truncate table Y&lt;br /&gt;              *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00604: error occurred at recursive SQL level 1&lt;br /&gt;ORA-20001: TRUNCATE not permitted&lt;br /&gt;ORA-06512: at line 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- oh ! there's an error. Let's ROLLBACK&lt;br /&gt;SQL&amp;gt; rollback;&lt;br /&gt;&lt;br /&gt;Rollback complete.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- is the data present in X ?&lt;br /&gt;SQL&amp;gt; select * from X ;&lt;br /&gt;&lt;br /&gt;  PRIMKEY DATA_&lt;br /&gt;---------- -----&lt;br /&gt;        1 QWERT&lt;br /&gt;        2 ASDF&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; -- HUH ?!  The TRUNCATE failed but the INSERT was committed !&lt;br /&gt;SQL&amp;gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Data that was INSERTed into X did not get rolled back although the TRUNCATE of Y failed. !  (Remember that the INSERT hadn't been committed so the transaction was still continuing and present till the TRUNCATE was issued).&lt;br /&gt;&lt;br /&gt;Why does this happen ? Let's see a trace :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; exec dbms_session.session_trace_enable;&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; truncate table Y;&lt;br /&gt;truncate table Y&lt;br /&gt;              *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00604: error occurred at recursive SQL level 1&lt;br /&gt;ORA-20001: TRUNCATE not permitted&lt;br /&gt;ORA-06512: at line 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;  &lt;/pre&gt;&lt;br /&gt;The trace file actually shows these events  in sequence :&lt;br /&gt;&lt;pre&gt;XCTEND rlbk=0, rd_only=1, tim=1309191962248722&lt;br /&gt;select count(FA#) from SYS_FBA_TRACKEDTABLES where OBJ# = 85567 and DROPSCN = 0&lt;br /&gt;LOCK TABLE "Y" IN EXCLUSIVE MODE  NOWAIT&lt;br /&gt;select count(FA#) from SYS_FBA_TRACKEDTABLES where OBJ# = 85567 and DROPSCN = 0&lt;br /&gt;truncate table Y&lt;br /&gt;begin&lt;br /&gt; raise_application_error(-20001,'TRUNCATE not permitted');&lt;br /&gt;end;&lt;br /&gt;declare&lt;br /&gt; m_stmt  varchar2(512);&lt;br /&gt;begin&lt;br /&gt;  m_stmt:='delete from sdo_geor_ddl__table$$';&lt;br /&gt;  EXECUTE IMMEDIATE m_stmt;&lt;br /&gt;  EXCEPTION&lt;br /&gt;    WHEN OTHERS THEN&lt;br /&gt;      NULL;&lt;br /&gt;end;&lt;br /&gt;.... and so on ... &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The first thing is the "XCTEND rlbk=0"  which is a COMMIT.  An Implicit COMMIT is issued by the TRUNCATE  irrespective of the actions in the trigger.&lt;br /&gt;&lt;br /&gt;For example, even if the trigger has an error it still causes a commit :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; create or replace trigger prevent_truncates&lt;br /&gt; 2  before truncate on schema&lt;br /&gt; 3  begin&lt;br /&gt; 4    raiseXXX_application_error(-20001,'TRUNCATE not permitted');&lt;br /&gt; 5  end;&lt;br /&gt; 6  /&lt;br /&gt;&lt;br /&gt;Warning: Trigger created with compilation errors.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; show errors&lt;br /&gt;Errors for TRIGGER PREVENT_TRUNCATES:&lt;br /&gt;&lt;br /&gt;LINE/COL ERROR&lt;br /&gt;-------- -----------------------------------------------------------------&lt;br /&gt;2/3      PL/SQL: Statement ignored&lt;br /&gt;2/3      PLS-00201: identifier 'RAISEXXX_APPLICATION_ERROR' must be&lt;br /&gt;        declared&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select status from user_triggers where trigger_name = 'PREVENT_TRUNCATES';&lt;br /&gt;&lt;br /&gt;STATUS&lt;br /&gt;--------&lt;br /&gt;ENABLED&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; create table Z (primkey number primary key, data_col varchar2(5));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into Z values (1,'abc');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into Z values (2,'def');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into Z values (3,'ghi');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; delete Z where primkey = 2 ;&lt;br /&gt;&lt;br /&gt;1 row deleted.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; truncate table Y;&lt;br /&gt;truncate table Y&lt;br /&gt;              *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-04098: trigger 'HEMANT.PREVENT_TRUNCATES' is invalid and failed re-validation&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; rollback;&lt;br /&gt;&lt;br /&gt;Rollback complete.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from Z;&lt;br /&gt;&lt;br /&gt;  PRIMKEY DATA_&lt;br /&gt;---------- -----&lt;br /&gt;        1 abc&lt;br /&gt;        3 ghi&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;  &lt;/pre&gt;&lt;br /&gt;The single row delete in table Z has been committed even though the TRUNCATE trigger has failed to execute properly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Remember : You as the DBA might put in a DDL trigger but a new developer (or even existing developer !) may not know about the presence of the trigger or the implications of the trigger !&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-2199611169750905477?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/2199611169750905477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=2199611169750905477' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2199611169750905477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2199611169750905477'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/ddl-triggers.html' title='DDL Triggers'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-6120702117243629241</id><published>2011-06-27T23:59:00.002+08:00</published><updated>2011-06-28T00:02:04.697+08:00</updated><title type='text'>Are you ready ?  (to buy bigger hardware or review your code ?)</title><content type='html'>Here's a video by Stephane Faroult (RoughSea)  :  "&lt;a href="http://youtu.be/5WPOUvzyLjc"&gt;Are you ready 2.0 ?&lt;/a&gt;"&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-6120702117243629241?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/6120702117243629241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=6120702117243629241' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6120702117243629241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6120702117243629241'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/are-you-ready-to-buy-bigger-hardware-or.html' title='Are you ready ?  (to buy bigger hardware or review your code ?)'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-6224466044966029293</id><published>2011-06-23T23:46:00.005+08:00</published><updated>2011-07-01T23:59:50.803+08:00</updated><title type='text'>How Are Students Learning Programming ?</title><content type='html'>A recent ComputerWorld article "&lt;a href="http://www.computerworld.com/s/article/9217820/How_are_students_learning_programming_in_a_post_Basic_world_"&gt;How are students learning programming in a post-Basic world ?&lt;/a&gt;" (It should be BASIC, not Basic) reminds me of the time I first learnt programming.&lt;br /&gt;&lt;div&gt;Yes, with BASIC. When there were very few PCs in Ahmedabad.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;I learnt programming with BASIC. The credit goes to my elder brother, Santosh, who convinced me (against my self-doubts) that I could learn computer programming. And once I started, it was SO EASY (I topped the class). &lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;b&gt;Thank you , Santosh.&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Here's a YABASIC program I wrote in 2007 to help my son solve a puzzle (and I don't remember the details of the puzzle) :&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;print "The problem of 3 daughters"&lt;br /&gt;print  "Find 3 numbers whose product equals the desired number"&lt;br /&gt;input "What is the product of the 3 integers ?"  productof3&lt;br /&gt;DIM AM(productof3,4)&lt;br /&gt;RN=1&lt;br /&gt;FOR I =1 to productof3&lt;br /&gt;IF INT(productof3/I) =  (productof3/I) THEN&lt;br /&gt;FOR J =1 to productof3&lt;br /&gt;IF INT(productof3/J) =  (productof3/J) THEN&lt;br /&gt;For K = 1 to productof3&lt;br /&gt; IF INT(productof3/K) =  (productof3/K) THEN&lt;br /&gt;#       print "Testing ", I , J , K&lt;br /&gt;        DOESEXIST=0&lt;br /&gt;      IF (I * J * K) = productof3 THEN&lt;br /&gt;#           print "Possible Answer : ", I , J, K, " :  With the Sum as : ", S\&lt;br /&gt;        FOR ARRCHK =1 to RN&lt;br /&gt;            S = I + J + K&lt;br /&gt;            IF ( (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=I AND AM(ARRCHK,3)=J AND AM(ARRCHK,4)=K) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=I AND AM(ARRCHK,3)=K AND AM(ARRCHK,4)=J) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=J AND AM(ARRCHK,3)=I AND AM(ARRCHK,4)=K) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=J AND AM(ARRCHK,3)=K AND AM(ARRCHK,4)=I) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=K AND AM(ARRCHK,3)=I AND AM(ARRCHK,4)=J) OR (AM(ARRCHK,1)=S AND AM(ARRCHK,2)=K AND AM(ARRCHK,3)=J AND AM(ARRCHK,4)=I)  )  THEN&lt;br /&gt;#                   print "..............   Numbers ", I, J, K, "  have already been checked"&lt;br /&gt;               DOESEXIST=1&lt;br /&gt;               BREAK&lt;br /&gt;              ENDIF&lt;br /&gt;        NEXT ARRCHK&lt;br /&gt;                IF DOESEXIST=0 THEN&lt;br /&gt;                  AM(RN,1)=S&lt;br /&gt;                  AM(RN,2)=I&lt;br /&gt;                  AM(RN,3)=J&lt;br /&gt;                  AM(RN,4)=K&lt;br /&gt;                  print "Possible Answer : " , AM(RN,2), AM(RN,3), AM(RN,4) , " : With the sum : ", AM(RN,1)&lt;br /&gt;                ENDIF&lt;br /&gt;         RN = RN +1&lt;br /&gt;     ENDIF&lt;br /&gt;  ENDIF&lt;br /&gt;NEXT K&lt;br /&gt;ENDIF&lt;br /&gt;NEXT J&lt;br /&gt;ENDIF&lt;br /&gt;NEXT I &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Or an example of a program to test a number for whether it is a Prime (very simplistic, not using any of the algorithms -- like the Sieve of Eratosthenes that I used when I wrote a program in the BASIC class in 1985 -- or was it in 1984) :&lt;br /&gt;&lt;pre&gt;print "hello world"&lt;br /&gt;# Testing for Prime Numbers&lt;br /&gt;#assign&lt;br /&gt;presult=0&lt;br /&gt;input "Which number ?"  numtotest&lt;br /&gt;print "You entered :  " , numtotest&lt;br /&gt;for I=2 to numtotest/2&lt;br /&gt;IF (numtotest/I) = int(numtotest/I) THEN&lt;br /&gt;# print "Testing division of ", numtotest, "by ", I , " : Is Not a Prime"&lt;br /&gt;presult=1&lt;br /&gt;BREAK&lt;br /&gt;ELSE&lt;br /&gt;# print "possibly a prime when testing division by  ", I&lt;br /&gt;ENDIF&lt;br /&gt;NEXT I&lt;br /&gt;clear screen&lt;br /&gt;if presult=0 then&lt;br /&gt;print colour("red","blue") numtotest,  "   IS A PRIME NUMBER !"&lt;br /&gt;ELSE&lt;br /&gt;print colour("green") numtotest,  "   is not a prime number !"&lt;br /&gt;ENDIF&lt;br /&gt;input "Enter to exit  " mentr &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I have also studied xBase (dBASEIII+), Pascal, C, C++ and Java (besides SQL and PL/SQL). Guess which language I dislike ? It is a 4 letter word.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;UPDATE 01-Jul-11 :  Here's an article by Joel Spolsky (albeit dated 29-Dec-05) : &lt;a href="http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html"&gt;The Perils of JavaSchools&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-6224466044966029293?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/6224466044966029293/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=6224466044966029293' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6224466044966029293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/6224466044966029293'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/how-are-students-learning-programming.html' title='How Are Students Learning Programming ?'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-83946569799957475</id><published>2011-06-21T22:22:00.004+08:00</published><updated>2011-06-22T15:33:50.957+08:00</updated><title type='text'>Oracle APAC Developer Program</title><content type='html'>Oracle ACEs in this part of the world had a conference call with Oracle's Program Executive for the APAC Developer Program.&lt;div&gt;We were provided information about forthcoming DBA Round Table and Developer Day sessions.  We were also given assurances that Oracle would continue supporting the ACE program and members.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thank you Shaheen.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-83946569799957475?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/83946569799957475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=83946569799957475' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/83946569799957475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/83946569799957475'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/oracle-apac-developer-program.html' title='Oracle APAC Developer Program'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7169183621111818453</id><published>2011-06-20T23:30:00.001+08:00</published><updated>2011-06-20T23:31:45.425+08:00</updated><title type='text'>OOW 2011 Content Catalog</title><content type='html'>The Oracle Open World 2011 &lt;a href="https://oracleus.wingateweb.com/scheduler/eventcatalog/eventCatalog.do"&gt;Content Catalog&lt;/a&gt; is now available for viewing.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7169183621111818453?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7169183621111818453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7169183621111818453' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7169183621111818453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7169183621111818453'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/oow-2011-content-catalog.html' title='OOW 2011 Content Catalog'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7933719260974062601</id><published>2011-06-20T22:33:00.003+08:00</published><updated>2011-06-22T23:46:12.088+08:00</updated><title type='text'>(OT) : Dead Media Never Really Die</title><content type='html'>See the ComputerWorld article : &lt;a href="http://www.computerworld.com/s/article/9217729/_Dead_media_never_really_die"&gt; 'Dead Media' never really die&lt;/a&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span id="yui-gen2" collapsed="false" showmore=" more" showless=" less"&gt;Dead Media never really die, it says. But I know of  hardware that is dead for all practical purposes. Surely there are formats that  are irretrievable now. What formats would you use for 20year / 50 year / 100  year / 200 year time capsules ? What about space exploration that may return to  Earth after centuries ? How do we read the data that the explorer has collected  ?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span id="yui-gen2" collapsed="false" showmore=" more" showless=" less"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-7933719260974062601?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/7933719260974062601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=7933719260974062601' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7933719260974062601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/7933719260974062601'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/ot-dead-media-never-really-die.html' title='(OT) : Dead Media Never Really Die'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-5936632750199579927</id><published>2011-06-14T12:51:00.001+08:00</published><updated>2011-06-14T12:53:18.741+08:00</updated><title type='text'>Precedence in Parallel Query specifications</title><content type='html'>The Datawarehouse Insider blog has posted a &lt;a href="http://blogs.oracle.com/datawarehousing/resource/px_precedence_overview.JPG"&gt;description of PX precedence&lt;/a&gt;. See the &lt;a href="http://blogs.oracle.com/datawarehousing/entry/parallel_execution_precedence_of_hints"&gt;blog post.&lt;/a&gt;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-5936632750199579927?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/5936632750199579927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=5936632750199579927' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5936632750199579927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/5936632750199579927'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/precedence-in-parallel-query.html' title='Precedence in Parallel Query specifications'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-3739205820141822626</id><published>2011-06-13T22:18:00.002+08:00</published><updated>2011-06-13T22:39:56.708+08:00</updated><title type='text'>Inequality and NULL</title><content type='html'>A response recent &lt;a href="http://forums.oracle.com/forums/thread.jspa?threadID=2236954"&gt;forums question&lt;/a&gt; about handling an inequality condition also reminded me, once again, about NULL handling in Oracle.&lt;br /&gt;&lt;br /&gt;You can have :&lt;br /&gt;&lt;pre&gt;WHERE column = 100 &lt;/pre&gt;in a query.&lt;br /&gt;&lt;br /&gt;In another query, you could have&lt;br /&gt;&lt;pre&gt;WHERE column != 100 &lt;/pre&gt;However, if the column does contain a NULL in any one (or more rows), the union of the two queries is not the entire table.  That is, rows with NULLs are excluded.&lt;br /&gt;You have to specifically handle NULLs with either&lt;br /&gt;&lt;pre&gt;IS NULL &lt;/pre&gt;or&lt;br /&gt;&lt;pre&gt;IS NOT NULL &lt;/pre&gt;depending on whether you want to explicitly include or exclude NULLs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here's a quick demo of the behaviour of NULLs :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; create table TEST_ROWS as&lt;br /&gt;2  select rownum as COLUMN_1,&lt;br /&gt;3  'Row Number :  ' || to_char(rownum) as COLUMN_2&lt;br /&gt;4  from dual connect by level &amp;lt; 11 ;&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; insert into TEST_ROWS values (NULL,'Row NULL');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select COLUMN_1, COLUMN_2 from TEST_ROWS order by 1 ;&lt;br /&gt;&lt;br /&gt;COLUMN_1 COLUMN_2&lt;br /&gt;---------- ------------------------------------------------------&lt;br /&gt;  1 Row Number :  1&lt;br /&gt;  2 Row Number :  2&lt;br /&gt;  3 Row Number :  3&lt;br /&gt;  4 Row Number :  4&lt;br /&gt;  5 Row Number :  5&lt;br /&gt;  6 Row Number :  6&lt;br /&gt;  7 Row Number :  7&lt;br /&gt;  8 Row Number :  8&lt;br /&gt;  9 Row Number :  9&lt;br /&gt; 10 Row Number :  10&lt;br /&gt;    Row NULL&lt;br /&gt;&lt;br /&gt;11 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select * from TEST_ROWS where COLUMN_1 != 6 order by 1;&lt;br /&gt;&lt;br /&gt;COLUMN_1 COLUMN_2&lt;br /&gt;---------- ------------------------------------------------------&lt;br /&gt;  1 Row Number :  1&lt;br /&gt;  2 Row Number :  2&lt;br /&gt;  3 Row Number :  3&lt;br /&gt;  4 Row Number :  4&lt;br /&gt;  5 Row Number :  5&lt;br /&gt;  7 Row Number :  7&lt;br /&gt;  8 Row Number :  8&lt;br /&gt;  9 Row Number :  9&lt;br /&gt; 10 Row Number :  10&lt;br /&gt;&lt;br /&gt;9 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Notice how the query for != 6  does *not* show the row with a NULL.&lt;br /&gt;Oracle does not say that a NULL is != 6.  A NULL is not comparable with 6 !&lt;br /&gt;The query has to be actually :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select * from TEST_ROWS&lt;br /&gt;2  where (COLUMN_1 != 6   OR  COLUMN_1 IS NULL)&lt;br /&gt;3  order by 1;&lt;br /&gt;&lt;br /&gt;COLUMN_1 COLUMN_2&lt;br /&gt;---------- ------------------------------------------------------&lt;br /&gt;  1 Row Number :  1&lt;br /&gt;  2 Row Number :  2&lt;br /&gt;  3 Row Number :  3&lt;br /&gt;  4 Row Number :  4&lt;br /&gt;  5 Row Number :  5&lt;br /&gt;  7 Row Number :  7&lt;br /&gt;  8 Row Number :  8&lt;br /&gt;  9 Row Number :  9&lt;br /&gt; 10 Row Number :  10&lt;br /&gt;    Row NULL&lt;br /&gt;&lt;br /&gt;10 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; &lt;/pre&gt;&lt;br /&gt;It is now that the row with a NULL appears !&lt;br /&gt;&lt;br /&gt;That is why such a count :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select count(*) from TEST_ROWS;&lt;br /&gt;&lt;br /&gt;COUNT(*)&lt;br /&gt;----------&lt;br /&gt; 11&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select count(*) from&lt;br /&gt;2  (select * from TEST_ROWS where COLUMN_1 = 6&lt;br /&gt;3  union&lt;br /&gt;4   select * from TEST_ROWS where COLUMN_1 != 6)&lt;br /&gt;5  /&lt;br /&gt;&lt;br /&gt;COUNT(*)&lt;br /&gt;----------&lt;br /&gt; 10&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select count(*) from&lt;br /&gt;2  (select * from TEST_ROWS where COLUMN_1 = 6&lt;br /&gt;3   union all&lt;br /&gt;4   select * from TEST_ROWS where COLUMN_1 != 6)&lt;br /&gt;5  /&lt;br /&gt;&lt;br /&gt;COUNT(*)&lt;br /&gt;----------&lt;br /&gt; 10&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;  &lt;/pre&gt;&lt;br /&gt;would fail because the union of the two result sets (equal to 6 and not-equal to 6) does not comprise of the whole set !&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-3739205820141822626?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/3739205820141822626/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=3739205820141822626' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3739205820141822626'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/3739205820141822626'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/inequality-and-null.html' title='Inequality and NULL'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-2931579385076156620</id><published>2011-06-13T14:22:00.002+08:00</published><updated>2011-06-13T14:25:22.614+08:00</updated><title type='text'>SQL Injection</title><content type='html'>&lt;p&gt;Here's a very simple example of &lt;a href="http://mikesmithers.wordpress.com/2011/06/07/oracle-bind-variables-and-sql-injection-keeping-out-unwanted-guests/"&gt;SQL Injection&lt;/a&gt; by Mike Smithers.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-2931579385076156620?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/2931579385076156620/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=2931579385076156620' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2931579385076156620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2931579385076156620'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/sql-injection.html' title='SQL Injection'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-2748954096203235011</id><published>2011-06-05T23:46:00.002+08:00</published><updated>2011-06-05T23:48:17.154+08:00</updated><title type='text'>New Presentation : On Nested Loop and Hash Join</title><content type='html'>I have uploaded a new presentation on &lt;a href="https://sites.google.com/site/hemantswebsite/oracle-diagnostics/OracleDiagnostics_Joins__1.pdf"&gt;Nested Loop and Hash Joins&lt;/a&gt;.  This is based on the "&lt;a href="http://hemantoracledba.blogspot.com/2011/06/nested-loop-and-consistent-gets.html"&gt;Nested Loops and Consistent Gets&lt;/a&gt;" case study.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1931548025515710472-2748954096203235011?l=hemantoracledba.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hemantoracledba.blogspot.com/feeds/2748954096203235011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1931548025515710472&amp;postID=2748954096203235011' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2748954096203235011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1931548025515710472/posts/default/2748954096203235011'/><link rel='alternate' type='text/html' href='http://hemantoracledba.blogspot.com/2011/06/new-presentation-on-nested-loop-and.html' title='New Presentation : On Nested Loop and Hash Join'/><author><name>Hemant K Chitale</name><uri>http://www.blogger.com/profile/07369112096230549250</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1931548025515710472.post-7538072090649748406</id><published>2011-06-05T14:33:00.006+08:00</published><updated>2011-06-05T15:23:07.492+08:00</updated><title type='text'>Getting the right statistics</title><content type='html'>Continuing with the post titled "&lt;a href="http://hemantoracledba.blogspot.com/2011/06/nested-loop-and-consistent-gets.html"&gt;Nested Loops and Consistent Gets&lt;/a&gt;" earlier today, what is the Execution Plan with statistics on more columns ?&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; exec dbms_stats.gather_table_stats('','TRANSACTIONS',estimate_percent=&amp;gt;100,granularity=&amp;gt;'ALL',-&lt;br /&gt;&amp;gt; method_opt=&amp;gt;'FOR COLUMNS COUNTRY_CD SIZE 250, PRODUCT_CD SIZE 250, TXN_ID SIZE 250 ',cascade=&amp;gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select column_name, num_distinct, histogram from user_tab_col_statistics&lt;br /&gt;2  where table_name = 'TRANSACTIONS'&lt;br /&gt;3  order by 1;&lt;br /&gt;&lt;br /&gt;COLUMN_NAME                    NUM_DISTINCT HISTOGRAM&lt;br /&gt;------------------------------ ------------ ---------------&lt;br /&gt;COUNTRY_CD                                5 FREQUENCY&lt;br /&gt;PRODUCT_CD                               10 FREQUENCY&lt;br /&gt;TXN_ID                              1000000 HEIGHT BALANCED&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; explain plan for&lt;br /&gt;2  select  product_desc, txn_id, transaction_amt&lt;br /&gt;3  from transactions t, product_table p&lt;br /&gt;4  where txn_date between to_date('01-FEB-2011','DD-MON-YYYY') and to_date('28-FEB-2011','DD-MON-YYYY')&lt;br /&gt;5  and txn_id between 155000 and 156000&lt;br /&gt;6  and country_cd = 'IN'&lt;br /&gt;7  and t.product_cd=p.product_cd&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 1299935411&lt;br /&gt;                                                                                                                 &lt;br /&gt;-------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                            | Name             | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |&lt;br /&gt;-------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT                     |                  |     1 |    45 |    36   (0)| 00:00:01 |       |       |&lt;br /&gt;|   1 |  NESTED LOOPS                        |                  |       |       |            |          |       |       |&lt;br /&gt;|   2 |   NESTED LOOPS                       |                  |     1 |    45 |    36   (0)| 00:00:01 |       |       |&lt;br /&gt;|   3 |    PARTITION RANGE SINGLE            |                  |     1 |    33 |    35   (0)| 00:00:01 |     2 |     2 |&lt;br /&gt;|*  4 |     TABLE ACCESS BY LOCAL INDEX ROWID| TRANSACTIONS     |     1 |    33 |    35   (0)| 00:00:01 |     2 |     2 |&lt;br /&gt;|*  5 |      INDEX RANGE SCAN                | TRANSACTIONS_NDX |   400 |       |     4   (0)| 00:00:01 |     2 |     2 |&lt;br /&gt;|*  6 |    INDEX UNIQUE SCAN                 | SYS_C0016611     |     1 |       |     0   (0)| 00:00:01 |       |       |&lt;br /&gt;|   7 |   TABLE ACCESS BY INDEX ROWID        | PRODUCT_TABLE    |     1 |    12 |     1   (0)| 00:00:01 |       |       |&lt;br /&gt;-------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;                                           &lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;                                                                            &lt;br /&gt;4 - filter("TXN_DATE"&amp;lt;=TO_DATE(' 2011-02-28 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))    5 - access("COUNTRY_CD"='IN' AND "TXN_ID"&amp;gt;=155000 AND "TXN_ID"&amp;lt;=156000)    6 - access("T"."PRODUCT_CD"="P"."PRODUCT_CD")  21 rows selected.  SQL&amp;gt; &lt;/pre&gt;&lt;br /&gt;Ah.  Now the optimizer has a better feel for the rows from Operation 5 : access by COUNTRY_CD and TXN_ID.  Instead of 252 rows (when column statistics were not gathered on TXN_ID), the expected row count is 400.&lt;br /&gt;Yet, the filter for TXN_DATE is still expected to return 1 row !  We know that we are reading 400 rows from the one partition alone(partition 2 being P_2011_FEB). We also know that all the rows in this partition *will* satisfy the criteria for this access predicate. Yet, the optimizer expects only 1 row.&lt;br /&gt;&lt;br /&gt;Here's the actual execution with this plan :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select /*+ gather_plan_statistics */ product_desc, txn_id, transaction_amt&lt;br /&gt;2  from transactions t, product_table p&lt;br /&gt;3  where txn_date between to_date('01-FEB-2011','DD-MON-YYYY') and to_date('28-FEB-2011','DD-MON-YYYY')&lt;br /&gt;4  and txn_id between 155000 and 156000&lt;br /&gt;5  and country_cd = 'IN'&lt;br /&gt;6  and t.product_cd=p.product_cd&lt;br /&gt;7  /&lt;br /&gt;&lt;br /&gt;PRODUCT_DESC                                           TXN_ID TRANSACTION_AMT&lt;br /&gt;-------------------------------------------------- ---------- ---------------&lt;br /&gt;Prod: _1                                               155000             155&lt;br /&gt;Prod: _2                                               155001         155.001&lt;br /&gt;Prod: _5                                               155004         155.004&lt;br /&gt;........&lt;br /&gt;Prod: _5                                               155994         155.994&lt;br /&gt;Prod: _9                                               155998         155.998&lt;br /&gt;Prod: _1                                               156000             156&lt;br /&gt;&lt;br /&gt;401 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display_cursor('','','ALLSTATS LAST'));&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;SQL_ID  5yzvvdg1y2aub, child number 0                                                                                           &lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ product_desc, txn_id,&lt;br /&gt;transaction_amt from transactions t, product_table p where txn_date&lt;br /&gt;between to_date('01-FEB-2011','DD-MON-YYYY') and&lt;br /&gt;to_date('28-FEB-2011','DD-MON-YYYY') and txn_id between 155000 and&lt;br /&gt;156000 and country_cd = 'IN' and t.product_cd=p.product_cd&lt;br /&gt;&lt;br /&gt;Plan hash value: 1299935411&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                            | Name             | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |&lt;br /&gt;----------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT                     |                  |      1 |        |    401 |00:00:00.03 |     428 |      2 |&lt;br /&gt;|   1 |  NESTED LOOPS                        |                  |      1 |        |    401 |00:00:00.03 |     428 |      2 |&lt;br /&gt;|   2 |   NESTED LOOPS                       |                  |      1 |      1 |    401 |00:00:00.04 |      27 |      1 |&lt;br /&gt;|   3 |    PARTITION RANGE SINGLE            |                  |      1 |      1 |    401 |00:00:00.02 |      23 |      0 |&lt;br /&gt;|*  4 |     TABLE ACCESS BY LOCAL INDEX ROWID| TRANSACTIONS     |      1 |      1 |    401 |00:00:00.02 |      23 |      0 |&lt;br /&gt;|*  5 |      INDEX RANGE SCAN                | TRANSACTIONS_NDX |      1 |    400 |    401 |00:00:00.01 |       6 |      0 |&lt;br /&gt;|*  6 |    INDEX UNIQUE SCAN                 | SYS_C0016611     |    401 |      1 |    401 |00:00:00.01 |       4 |      1 |&lt;br /&gt;|   7 |   TABLE ACCESS BY INDEX ROWID        | PRODUCT_TABLE    |    401 |      1 |    401 |00:00:00.01 |     401 |      1 |&lt;br /&gt;----------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;4 - filter("TXN_DATE"&amp;lt;=TO_DATE(' 2011-02-28 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))    5 - access("COUNTRY_CD"='IN' AND "TXN_ID"&amp;gt;=155000 AND "TXN_ID"&amp;lt;=156000)    6 - access("T"."PRODUCT_CD"="P"."PRODUCT_CD")   30 rows selected.  SQL&amp;gt; &lt;/pre&gt;&lt;br /&gt;So ! We are still reading the PRODUCTS_TABLE  400 times --- only because the Optimizer expected to have to read it only once !&lt;br /&gt;&lt;br /&gt;Therefore, we can now narrow down to the determination of the row count for the filter predicate for TXN_DATE as being the cause of the "poor" behaviour of this Nested Loop, with a high Consistent Gets count.&lt;br /&gt;The current set of statistics do not include a column where our query predicate is actually " txn_date between to_date('01-FEB-2011','DD-MON-YYYY') and to_date('28-FEB-2011','DD-MON-YYYY')" and the result is that the query is sub-optimal.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What if we include TXN_DATE in our statistics as well :&lt;div&gt;.......... we'll now see the Join change to a &lt;b&gt;Sort-Merge&lt;/b&gt; join !&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; exec dbms_stats.gather_table_stats('','TRANSACTIONS',estimate_percent=&amp;gt;100,granularity=&amp;gt;'ALL',-&lt;br /&gt;&amp;gt; method_opt=&amp;gt;'FOR COLUMNS COUNTRY_CD SIZE 250, PRODUCT_CD SIZE 250, TXN_ID SIZE 250, TXN_DATE SIZE 250 ',cascade=&amp;gt;TRUE);&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select column_name, num_distinct, histogram from user_tab_col_statistics&lt;br /&gt;2  where table_name = 'TRANSACTIONS'&lt;br /&gt;3  order by 1;&lt;br /&gt;&lt;br /&gt;COLUMN_NAME                    NUM_DISTINCT HISTOGRAM&lt;br /&gt;------------------------------ ------------ ---------------&lt;br /&gt;COUNTRY_CD                                5 FREQUENCY&lt;br /&gt;PRODUCT_CD                               10 FREQUENCY&lt;br /&gt;TXN_DATE                            1000000 HEIGHT BALANCED&lt;br /&gt;TXN_ID                              1000000 HEIGHT BALANCED&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; explain plan for&lt;br /&gt;2  select  product_desc, txn_id, transaction_amt&lt;br /&gt;3  from transactions t, product_table p&lt;br /&gt;4  where txn_date between to_date('01-FEB-2011','DD-MON-YYYY') and to_date('28-FEB-2011','DD-MON-YYYY')&lt;br /&gt;5  and txn_id between 155000 and 156000&lt;br /&gt;6  and country_cd = 'IN'&lt;br /&gt;7  and t.product_cd=p.product_cd&lt;br /&gt;8  /&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 3745290717&lt;br /&gt;&lt;br /&gt;-------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                            | Name             | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |&lt;br /&gt;-------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT                     |                  |   386 | 16984 |    38   (3)| 00:00:01 |       |       |&lt;br /&gt;|   1 |  MERGE JOIN                          |                  |   386 | 16984 |    38   (3)| 00:00:01 |       |       |&lt;br /&gt;|   2 |   TABLE ACCESS BY INDEX ROWID        | PRODUCT_TABLE    |    14 |   168 |     2   (0)| 00:00:01 |       |       |&lt;br /&gt;|   3 |    INDEX FULL SCAN                   | SYS_C0016611     |    14 |       |     1   (0)| 00:00:01 |       |       |&lt;br /&gt;|*  4 |   SORT JOIN                          |                  |   386 | 12352 |    36   (3)| 00:00:01 |       |       |&lt;br /&gt;|   5 |    PARTITION RANGE SINGLE            |                  |   386 | 12352 |    35   (0)| 00:00:01 |     2 |     2 |&lt;br /&gt;|*  6 |     TABLE ACCESS BY LOCAL INDEX ROWID| TRANSACTIONS     |   386 | 12352 |    35   (0)| 00:00:01 |     2 |     2 |&lt;br /&gt;|*  7 |      INDEX RANGE SCAN                | TRANSACTIONS_NDX |   400 |       |     4   (0)| 00:00:01 |     2 |     2 |&lt;br /&gt;-------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;4 - access("T"."PRODUCT_CD"="P"."PRODUCT_CD")&lt;br /&gt;    filter("T"."PRODUCT_CD"="P"."PRODUCT_CD")&lt;br /&gt;6 - filter("TXN_DATE"&amp;lt;=TO_DATE(' 2011-02-28 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))    7 - access("COUNTRY_CD"='IN' AND "TXN_ID"&amp;gt;=155000 AND "TXN_ID"&amp;lt;=156000)  22 rows selected.  SQL&amp;gt; &lt;/pre&gt;&lt;br /&gt;It's a very different execution plan now.  The Optimizer estimates 386 rows from TRANSACTIONS after filtering for the TXN_DATE.  It now chooses to do a Sort-Merge join (instead of the Nested Loop), starting with a read of the PRODUCTS_TABLE.&lt;br /&gt;The opitmizer will now avoid the "mistake" of reading the PRODUCTS_TABLE 41 times.&lt;br /&gt;Here's the actual execution :&lt;br /&gt;&lt;pre&gt;SQL&amp;gt; select /*+ gather_plan_statistics */ product_desc, txn_id, transaction_amt&lt;br /&gt;2  from transactions t, product_table p&lt;br /&gt;3  where txn_date between to_date('01-FEB-2011','DD-MON-YYYY') and to_date('28-FEB-2011','DD-MON-YYYY')&lt;br /&gt;4  and txn_id between 155000 and 156000&lt;br /&gt;5  and country_cd = 'IN'&lt;br /&gt;6  and t.product_cd=p.product_cd&lt;br /&gt;7  /&lt;br /&gt;&lt;br /&gt;PRODUCT_DESC                                           TXN_ID TRANSACTION_AMT&lt;br /&gt;-------------------------------------------------- ---------- ---------------&lt;br /&gt;Prod: _1                                               155000             155&lt;br /&gt;Prod: _1                                               155010          155.01&lt;br /&gt;Prod: _1                                               155020          155.02&lt;br /&gt;........&lt;br /&gt;Prod: _9                                               155618         155.618                                                    &lt;br /&gt;Prod: _9                                               155628         155.628&lt;br /&gt;Prod: _9                                               155638         155.638&lt;br /&gt;&lt;br /&gt;401 rows selected.&lt;br /&gt;&lt;br /&gt;SQL&amp;gt;&lt;br /&gt;SQL&amp;gt; select * from table(dbms_xplan.display_cursor('','','ALLSTATS LAST'));&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;SQL_ID  5yzvvdg1y2aub, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ product_desc, txn_id,&lt;br /&gt;transaction_amt from transactions t, product_table p where txn_date&lt;br /&gt;between to_date('01-FEB-2011','DD-MON-YYYY') and&lt;br /&gt;to_date('28-FEB-2011','DD-MON-YYYY') and txn_id between 155000 and&lt;br /&gt;156000 and country_cd = 'IN' and t.product_cd=p.product_cd&lt;br /&gt;&lt;br /&gt;Plan hash value: 3745290717&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;-------------------&lt;br /&gt;&lt;br /&gt;| Id  | Operation                            | Name             | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |&lt;br /&gt;1Mem | Used-Mem |&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;-------------------&lt;br /&gt;&lt;br /&gt;|   0 | SELECT STATEMENT                     |         
