`

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

 

 

 

分享到:
评论

相关推荐

    MySQL驱动 mysql-connector-net-6.4.3

    这款驱动程序由Oracle公司提供,是.NET Framework的一个组件,使得.NET开发者能够充分利用MySQL的强大功能。 首先,我们来了解一下MySQL数据库。MySQL是一个流行的开源关系型数据库管理系统(RDBMS),以其高效、...

    MySQL或Oracle通过ODBC与C#建立连接和进行事务处理

    ### MySQL或Oracle通过ODBC与C#建立连接和进行事务处理 #### 一、概述 在现代企业级应用开发中,数据库的选择对于整个系统的稳定性和性能有着至关重要的影响。随着多语言开发的需求日益增长,如何让不同的编程语言...

    mysql-connector-net-8.0.13.rar_.NET MYSQL_C#_MYSQL

    首先,MySQL Connector/Net是Oracle公司为.NET开发者提供的一个开源、免费的数据库连接器。它遵循ADO.NET规范,使得.NET应用程序能够无缝地连接到MySQL服务器,执行SQL语句,处理结果集,进行事务处理等。该驱动程序...

    MySql.Data.dll8.0类库

    1. **MySQL Connector/NET**:MySQL.Data.dll是MySQL Connector/NET的一部分,这是一个开源的.NET数据提供程序,由Oracle公司维护。它实现了ADO.NET接口,使得.NET开发者可以像操作其他.NET数据库一样操作MySQL。 2...

    sql详解-oracle

    它不仅被广泛应用于多种数据库系统,如Oracle、MySQL、SQL Server等,还支持多种操作,包括数据查询、更新、定义及控制。 #### 二、SQL的数据类型 SQL支持多种数据类型,每种类型都有其特定用途: - **NUMBER**: ...

    Mysql.Data(.net3.5;4.0).dll

    MySQL.Data.dll是Oracle MySQL针对.NET Framework的一个适配器,它包含了.NET应用程序与MySQL服务器通信所需的所有组件。这个库不仅支持标准的SQL查询,还提供了事务处理、存储过程调用、连接池等高级功能。在.NET ...

    MySql.Data.zip_MYSQL_MySql.Data_c# MySql.Data.dll_c# mysql_数据库

    这个库由Oracle公司提供,使得C#程序员能够轻松地在他们的应用程序中集成MySQL数据库的功能。MySQL.Data.dll是这个库的核心组件,包含了必要的类和方法来执行SQL查询、管理数据库连接、处理事务等。 首先,我们来看...

    MySql.Data.dll.rar

    MySQL.Data.dll是MySQL数据库连接器的一个重要组件,它是.NET开发者用来与MySQL服务器进行交互的库。这个RAR压缩包可能包含了该DLL文件以及相关的文档或示例代码,方便开发者在他们的.NET应用程序中集成MySQL数据库...

    MySql.Data.dll

    5. **事务处理**:MySQL.Data.dll支持事务处理,你可以使用`MySqlConnection`的`BeginTransaction()`方法开始一个事务,然后在一组操作完成后调用`Commit()`或在发生错误时调用`Rollback()`。 6. **参数化查询**:...

    MySql.Data.dll及使用

    MySQL.Data.dll是MySQL数据库连接器的一个重要组成部分,它是由Oracle公司为.NET开发者提供的,使得.NET应用程序能够方便地与MySQL数据库进行交互。这个库包含了连接、查询、事务处理等各种功能,支持多种版本的...

    MySQL常用命令.md

    datadir=D:\Program Files\mysql-5.7\data\ port=3306 ``` 5. **安装与初始化服务**: - 启动管理员模式下的 CMD,切换到 MySQL 的 `bin` 目录。 - 输入 `mysqld –install` 命令来安装 MySQL 服务。 - 运行 `...

    C# MySQL 数据库操作类 (包含MySql.Data.Dll文件) 常用方法二三十多个

    这是一个由Oracle官方提供的MySQL .NET数据提供程序,它允许.NET开发者通过C#或其他.NET语言与MySQL服务器进行通信。该库提供了连接管理、命令执行、事务处理等功能,是连接C#与MySQL不可或缺的组件。 `...

    mysql.data.dll

    MySQL.data.dll是MySQL数据库连接C#应用程序的关键组件,它提供了.NET开发者用来与MySQL服务器交互的接口。这个库是由Oracle公司维护并更新,是MySQL Connector/NET的一部分,支持.NET Framework的各种版本,使得C#...

    MySql.Data

    事务处理在数据库操作中是至关重要的,MySQL.Data通过MySqlConnection的BeginTransaction、Commit和Rollback方法提供了事务支持。这使得多条SQL语句作为一个单元执行,确保数据的一致性。 此外,MySQLDataAdapter和...

    MySQL初级与高级教程

    - MySQL发展历史:MySQL由瑞典MySQL AB公司开发,后被Sun Microsystems收购,最终成为Oracle旗下产品。 - MySQL特点:开源免费、轻量级、高性能、跨平台支持。 - MySQL应用场景:网站服务器、应用软件服务器等。 ...

    data-348025.pdf

    【MySQL与Oracle系统学习】 在IT领域,数据库管理和SQL语言是至关重要的技能。本文将深入探讨MySQL和Oracle两大主流数据库系统的学习,以及SQL语言的基本概念和应用。 **一、开篇立意** 学习数据库和SQL语言是...

    oracle+MySQL+jdbc数据库教程

    ### Oracle+MySQL+jdbc数据库教程知识点详解 #### 一、Oracle和MySQL基础知识 **1. 数据库基本概念** - **数据库定义**:一种用于存储、管理和检索数据的系统。 - **关系型数据库**:采用表格形式组织数据,通过行...

Global site tag (gtag.js) - Google Analytics