{"id":121,"date":"2016-04-17T15:50:03","date_gmt":"2016-04-17T15:50:03","guid":{"rendered":"https:\/\/www.spotonoracle.com\/?p=121"},"modified":"2016-05-10T16:34:29","modified_gmt":"2016-05-10T16:34:29","slug":"rman-in-first_rows-hell","status":"publish","type":"post","link":"https:\/\/www.spotonoracle.com\/?p=121","title":{"rendered":"RMAN in FIRST_ROWS hell"},"content":{"rendered":"<p>A short while back I was doing a database upgrade\/migration from 11.2.0.1 to 12.1.0.2 to a new server. To keep the downtime of the 850GB big database short I used Transportable Tablespaces together with <a href=\"http:\/\/docs.oracle.com\/cd\/E11882_01\/backup.112\/e10642\/rcmbckba.htm#BRADV8186\" target=\"_blank\">incrementally updated backups<\/a> where the datafile copies are placed on the target machine&#8217;s storage using a shared mount. So, during the downtime (as soon as the Tablespaces are set READ ONLY) all there&#8217;s left is doing the last inc 1 backup and the meta data export \/ import. Everything went fine on all test databases which were freshly cloned from production.<br \/>\nBut then, around comes time for production. I started taking the inc 0 datafile copy backups a few days before. Eight long hours later I was ready to take inc 1 backups from time to time and apply them on the datafile copies. This is where all the good plans went south. Every time the &#8220;BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG&#8230;&#8221; command ran it took about 23 seconds before RMAN actually started taking the backup. During the production downtime this is probably fine if there&#8217;s only 5 datafiles. Our database had more than 50 datafiles. And, you have to account for 50 x 23 seconds for the &#8220;RECOVER COPY OF DATAFILE&#8230;&#8221; command as well as the same problem applies there, too. Clearly, this issue needed resolving before the production downtime.<\/p>\n<p>My investigation showed that above RMAN commands trigger the calling of DBMS_RCVMAN.getRcvRec which in turn calls DBMS_RCVMAN.getDataFileCopy. In there are some complex queries involving V$BACKUPSET, V$DATAFILE_COPY, etc. and one of these queries did have a very bad execution plan. First I thought there might be a problem with the object statistics on the underlying X$ tables, namely X$KCCBF, X$KCCBP and X$KCCBC. OK, the stats were somewhat stale so I gathered them for the involved X$ tables. Unfortunately, this didn&#8217;t solve the problem of the bad execution plan. Then, I remembered that during the initial analysis of the database I noticed that OPTIMIZER_MODE was set to FIRST_ROWS on the instance level (for whatever reason the SW vendor claimed this was best). Of course, this setting also affected RMAN. As the database was still fully productive I couldn&#8217;t just change the parameter to ALL_ROWS. Setting up a login trigger for RMAN seemed too intrusive. The solution was simple: run an ALTER SESSION at the start of the RMAN session and all is fine&#8230;<\/p>\n<pre class=\"brush: sql; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\nsql &quot;alter session set optimizer_mode = ALL_ROWS&quot;;\r\n<\/pre>\n<p>Btw., on the new 12.1.0.2 database the application runs just perfectly with ALL_ROWS \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A short while back I was doing a database upgrade\/migration from 11.2.0.1 to 12.1.0.2 to a new server. To keep the downtime of the 850GB big database short I used Transportable Tablespaces together with incrementally updated backups where the datafile copies are placed on the target machine&#8217;s storage using a shared mount. So, during the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10,13],"tags":[],"class_list":["post-121","post","type-post","status-publish","format-standard","hentry","category-internals","category-rman","category-things-that-happen"],"_links":{"self":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=121"}],"version-history":[{"count":2,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/121\/revisions"}],"predecessor-version":[{"id":123,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/121\/revisions\/123"}],"wp:attachment":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}