`

Data rollback (MySQL -》 Oracle)

 
阅读更多

 

 

<!--[if !supportLists]-->1.       <!--[endif]-->For the SQL  DEL_ORACLE_DATA. I think we can use truncate to replace delete. Because truncate is faster than delete.

We can update it to be:

public final static String DEL_ORACLE_DATA = "begin for cur in (select owner, table_name from all_tables where owner = ''{0}'') loop execute immediate ''truncate table ''||cur.owner||''.''||cur.table_name || '' drop storage '';end loop; end;";

 

<!--[if !supportLists]-->2.       <!--[endif]--> For the exception:

 at java.lang.OutOfMemoryError.<init>()V (OutOfMemoryError.java:25)

 at oracle.jdbc.driver.OraclePreparedStatement.setupBindBuffers(II)V (OraclePreparedStatement.java:2764)

 at oracle.jdbc.driver.OraclePreparedStatement.executeBatch()[I (OraclePreparedStatement.java:9314)

 at oracle.jdbc.driver.OracleStatementWrapper.executeBatch()[I (OracleStatementWrapper.java:211)

 

I thread dump when the tool throw out of  memory exception, and use the tool eclipse memory analyzer to analyze, found the inputStream use 73.51% memory and  lastboundChars use 25.18% memory. (you can see the bellow picture)

Inputstream is used to store the blob column, lastboundChars is used to bound chars. I found the size for array inputStream is 32768. It is a little strange, because my batch size is 20000.

 

I watch the source code, found  when the numberof bind rows allocated is less than the rows need,   numberOfBindRowsAllocated will be double, and growBinds.  For example, when the size is bigger than 16384, then numberOfBindRowsAllocated will be 32768.

So it is the reason why my batch size is 20000, but the inputstream array size is 32768.  In this case, I think we can set the size to be 16380 to fully use the memory.

 

      if (i2 >= this.numberOfBindRowsAllocated)

      {

        int i3 = this.numberOfBindRowsAllocated << 1;

 

        if (i3 <= i2) {

          i3 = i2 + 1;

        }

        growBinds(i3);

 

        this.currentBatchNeedToPrepareBinds = true;

      }

<!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter" /> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0" /> <v:f eqn="sum @0 1 0" /> <v:f eqn="sum 0 0 @1" /> <v:f eqn="prod @2 1 2" /> <v:f eqn="prod @3 21600 pixelWidth" /> <v:f eqn="prod @3 21600 pixelHeight" /> <v:f eqn="sum @0 0 1" /> <v:f eqn="prod @6 1 2" /> <v:f eqn="prod @7 21600 pixelWidth" /> <v:f eqn="sum @8 21600 0" /> <v:f eqn="prod @7 21600 pixelHeight" /> <v:f eqn="sum @10 21600 0" /> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" /> <o:lock v:ext="edit" aspectratio="t" /> </v:shapetype><v:shape id="Picture_x0020_2" o:spid="_x0000_i1026" type="#_x0000_t75" alt="Description: Description: C:\Users\ffan\AppData\Roaming\Tencent\Users\407178982\QQ\WinTemp\RichOle\OQ}H])NEU)QVR$42E{EQ{8W.jpg" style='width:501.75pt;height:334.5pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\ffan\AppData\Local\Temp\msohtmlclip1\01\clip_image001.jpg" o:title="OQ}H])NEU)QVR$42E{EQ{8W" /> </v:shape><![endif]--><!--[if !vml]-->Description: Description: C:\Users\ffan\AppData\Roaming\Tencent\Users\407178982\QQ\WinTemp\RichOle\OQ}H])NEU)QVR$42E{EQ{8W.jpg<!--[endif]-->

<!--[if gte vml 1]><v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" alt="Description: Description: C:\Users\ffan\AppData\Roaming\Tencent\Users\407178982\QQ\WinTemp\RichOle\8EJ8VC(Z2K5)63UNKC]K3EX.jpg" style='width:546pt;height:379.5pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\ffan\AppData\Local\Temp\msohtmlclip1\01\clip_image002.jpg" o:title="8EJ8VC(Z2K5)63UNKC]K3EX" /> </v:shape><![endif]--><!--[if !vml]-->Description: Description: C:\Users\ffan\AppData\Roaming\Tencent\Users\407178982\QQ\WinTemp\RichOle\8EJ8VC(Z2K5)63UNKC]K3EX.jpg<!--[endif]-->

<!--[if !supportLists]-->3.      <!--[endif]-->  I found in our tool, we do not disable the log. Also do not drop the index, after disable log and drop the index, the speed improved a lot.

 

public final static String DISABLE_ORACLE_LOG = "begin for cur in (select owner, table_name from all_tables where owner = ''{0}'') loop execute immediate ''ALTER table ''||cur.owner||''.''||cur.table_name || '' nologging '';end loop; end;";

public final static String DROP_ORACLE_INDEX = "begin for cur in (select owner, object_name from all_objects  where object_type=''INDEX'' and owner = ''{0}'') loop execute immediate '' drop index ''||cur.owner||''.''||cur.object_name;end loop; end;";

 

 

                Line 81: 2012-09-10 09:46:46,984 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] Dynamic SQL template in TABLE endpoint is: insert into endpoint (model,locale,hardware_id,brandid,trigger_port,type,num_triggers,version,codec6,id,noc_id,codec7,codec8,codec9,created,description,trigger_prefix,last_trigger_ts,os,nf_delivery_type,last_connection_date,vendor,msisdn,msisdn_validated,codec1,codec0,codec5,codec4,codec3,modified,device_uid,os_version,codec2,ip,extra_codecs_id,csc,provisioning_id,imsi,device_group,public_key,ekey) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

                Line 81: 2012-09-10 09:46:46,984 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] Dynamic SQL template in TABLE endpoint is: insert into endpoint (model,locale,hardware_id,brandid,trigger_port,type,num_triggers,version,codec6,id,noc_id,codec7,codec8,codec9,created,description,trigger_prefix,last_trigger_ts,os,nf_delivery_type,last_connection_date,vendor,msisdn,msisdn_validated,codec1,codec0,codec5,codec4,codec3,modified,device_uid,os_version,codec2,ip,extra_codecs_id,csc,provisioning_id,imsi,device_group,public_key,ekey) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

                Line 125: 2012-09-10 09:46:51,815 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] ========== Table Name : endpoint, Now counter = 16380 start commit time:Mon Sep 10 09:46:51 CST 2012

                Line 128: 2012-09-10 09:46:55,406 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] ========== Table Name : endpoint, Now counter = 16380 end commit time:Mon Sep 10 09:46:55 CST 2012

                Line 143: 2012-09-10 09:47:03,123 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] ========== Table Name : endpoint, Now counter = 32760 start commit time:Mon Sep 10 09:47:03 CST 2012

                Line 146: 2012-09-10 09:47:04,306 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] ========== Table Name : endpoint, Now counter = 32760 end commit time:Mon Sep 10 09:47:04 CST 2012

                Line 159: 2012-09-10 09:47:12,439 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] ========== Table Name : endpoint, Now counter = 49140 start commit time:Mon Sep 10 09:47:12 CST 2012

                Line 160: 2012-09-10 09:47:12,730 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] ========== Table Name : endpoint, Now counter = 49140 end commit time:Mon Sep 10 09:47:12 CST 2012

                Line 175: 2012-09-10 09:47:22,810 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] ========== Table Name : endpoint, Now counter = 65520 start commit time:Mon Sep 10 09:47:22 CST 2012

                Line 176: 2012-09-10 09:47:23,250 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] ========== Table Name : endpoint, Now counter = 65520 end commit time:Mon Sep 10 09:47:23 CST 2012

                Line 191: 2012-09-10 09:47:33,913 [pool-4-thread-1] [INFO  com.seven.migrate.job.RollbackJobForBlobTable] ========== Table Name : endpoint, Now counter = 81900 start commit time:Mon Sep 10 09:47:33 CST 2012

 

 

<!--[if !supportLists]-->4.       <!--[endif]-->If the speed still not perfect. For oracle we also can consider to set a table with a table space for oracle,  and use oracle parallel execution. For MySQL we can consider change the environment property of MySQL to improve the read speed of MySQL.

               http://blog.csdn.net/tianlesoftware/article/details/5854583

 

 

 

分享到:
评论

相关推荐

    数据库.txt

    常见的数据库管理软件:甲骨文的oracle,IBM的db2,sql server, Access,MySQL(开源,免费,跨平台). 数据库系统 数据库系统DBS(Data Base System,简称DBS)通常由软件、数据库和数据管理员组成。 软件主要包括...

    第一章数据库的简介.docx

    常见的数据库管理软件:甲骨文的oracle,IBM的db2,sql server, Access,MySQL(开源,免费,跨平台). 数据库系统 数据库系统DBS(Data Base System,简称DBS)通常由软件、数据库和数据管理员组成。 软件主要包括...

    oracle学习文档 笔记 全面 深刻 详细 通俗易懂 doc word格式 清晰 连接字符串

    常见的有Oracle、mssql、mysql等 二、 主流数据库 数据库名 公司 特点 工作环境 mssql 微软 只能能运行在windows平台,体积比较庞大,占用许多系统资源, 但使用很方便,支持命令和图形化管理,收费。 中型企业 ...

    SQL必知必会(第3版)--详细书签版

    B.1 使用Aqua Data Studio 157 B.2 使用DB2 158 B.3 使用Macromedia ColdFusion 159 B.4 使用Microsoft Access 159 B.5 使用Microsoft ASP 160 B.6 使用Microsoft ASP.NET 161 B.7 使用Microsoft Query 161 ...

    SQL培训第一期

    2.2 Oracle与Mysql差异 2.2.1 Group by 2.2.1.1 Oracle select后面出现的列,如果没有使用集合函数,必须出现在group by 中。 select sno,sname,sum(grade) from student group by sno,sname; //合法写法 select...

    Delphi7.1 Update

    * TClientDataSet doesn‘t save data to file when FileName is set and there is no existing file on disk (Quality Central 2307). * Using the Delphi 7 version of midas.dll to open an XML file that was ...

    2009达内SQL学习笔记

    export ORACLE_HOME=/oracledata/.../bin: 一、注意事项: 大小写不敏感,即不区分大小写。提倡关键字大写,便于阅读和调式。 “!”在SQL环境下执行Unix命令。 SQL语句是由简单的英语单词构成;这些英语单词...

    SQL必知必会(第3版 中文高清版)

     b.1 使用aqua data studio   b.2 使用db2   b.3 使用macromedia coldfusion   b.4 使用microsoft access   b.5 使用microsoft asp   b.6 使用microsoft asp.net   b.7 使用microsoft query  ...

    hibernate.properties

    #hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver #hibernate.connection.username ora #hibernate.connection.password ora #hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl...

    SQL必知必会(第3版-PDF清晰版)part1

    B.1 使用Aqua Data Studio.. 157 B.2 使用DB2.. 158 B.3 使用Macromedia ColdFusion.. 159 B.4 使用Microsoft Access.. 159 B.5 使用Microsoft ASP... 160 B.6 使用Microsoft ASP.NET... 161 B.7 使用Microsoft ...

    经典全面的SQL语句大全

     DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK)  首先,简要介绍基础语句:  1、说明:创建数据库 CREATE DATABASE database-name  2、说明:删除数据库 drop database dbname  3、说明:备份sql server ...

Global site tag (gtag.js) - Google Analytics