{"id":529,"date":"2009-09-25T17:09:27","date_gmt":"2009-09-25T22:09:27","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=529"},"modified":"2011-07-06T09:36:51","modified_gmt":"2011-07-06T14:36:51","slug":"how-long-will-my-flashback-database-command-take","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2009\/09\/25\/how-long-will-my-flashback-database-command-take\/","title":{"rendered":"How long will my flashback database command take?!!"},"content":{"rendered":"<p>Oracle 10g introduced the wonderful (and I mean wonderful) ability to &#8220;rewind&#8221; a database back to a point in time, rather than restoring a backup and rolling it forward in time using transaction logs.  This technology is called flashback database, and googling it will provide far more useful information than I can in my small blog.<\/p>\n<p>One limitation is that when you issue the flashback database command, you have literally no clue how long it will take to complete.  It doesn&#8217;t show up in v$session_longops, and it only shows &#8220;control file sequential read&#8221; in v$session_event.  I did find a way to come very close to estimating how long it has left to complete, though.<\/p>\n<p>Basically, you compare the statistic value for &#8220;physical read total bytes&#8221; for the session and compare it to the size of the flashback restore point you created.  When these equal, you are a minute or two from completion.<\/p>\n<pre lang=\"python\" line=\"1\">\r\n#!\/home\/oracle\/local\/bin\/python\r\nimport cx_Oracle\r\nimport sys\r\nimport time\r\n\r\ncon = cx_Oracle.Connection(\"rman\",\"*****\",\"wcprod\",cx_Oracle.SYSDBA)\r\ncursor = con.cursor()\r\n\r\ncursor.execute(\"select value from v$sesstat where sid = 1634 and statistic# = (select statistic# from v$statname where name = 'physical read total bytes')\")\r\nfor row in cursor.fetchall():\r\n  total=int(row[0])\r\n\r\ncursor.execute(\"select to_char(storage_size) from v$restore_point\")\r\nfor row in cursor.fetchall():\r\n  print str(int(row[0])\/1024\/1024) + \"mb flashback size, and \" + str(total\/1024\/1024) + \"mb read, for a difference of \" + str((int(row[0]) - total) \/ 1024 \/ 1024) + \"mb.\"\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Oracle 10g introduced the wonderful (and I mean wonderful) ability to &#8220;rewind&#8221; a database back to a point in time, rather than restoring a backup and rolling it forward in time using transaction logs. This technology is called flashback database,&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2009\/09\/25\/how-long-will-my-flashback-database-command-take\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,24,22,26],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/529"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=529"}],"version-history":[{"count":8,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/529\/revisions"}],"predecessor-version":[{"id":1272,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/529\/revisions\/1272"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=529"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}