Large DML insert/update hanging tips

简介:

 

Expert Oracle Tips by Burleson Consulting
August 24, 2010

Question:  We were trying to insert approximately 76 million rows with about 4 gigabytes of space with a batch job when the insert operation failed with the archive log error.  What are the best practices for performing large batch insert jobs to avoid hanging?
Answer: When you run a large batch insert or updates job you risk aborting with:

1 – Insert aborts with a ORA-01555 snapshot too old

2 - Insert hangs when your archive redo log directory becomes full.

There are several approaches to performing large batch update or tuning insert jobs:

  • Divide and Conquer:  Make the job re-startable and commit every 1 5 minutes to release held rollback segments (undo logs).
  • Check space in archived redo log filesystem:  Make sure that you have enough spaced to hold all of the new archived redo logs.  See my notes on monitoring Oracle redo log activity.
  • Dedicated undo: Assign a giant, dedicated rollback segment to the batch job, large enough to hold all of the before images for any updates.
  • Parallelize the insert job:  There are two types of parallelism for large DML jobs:  
    (1) You can use parallel DML, or 
    (2) submit multiple simultaneous insert jobs, making sure to you have enough freelists allocated to the table to prevent buffer busy waits.  
    Multiple freelists add additional segment header blocks, removing the bottleneck.  You can also use Automatic Segment Space Management (bitmap freelists) to support parallel DML, but ASSM has some limitations.
  • Bulk DML: Consider using PL/SQL bulk operators to improve load speed by reducing context switching.
  • Consider NOLOGGING: Take a full backup first and run the insert with the NOLOGGING clause.  Note:  INSERT APPEND supports only the subquery syntax of the INSERT statement, not the VALUES clause. For more information on the subquery syntax of INSERT statements see Oracle nologging tips.
  • Use insert append: Using the “append” hint to your insert ensures that you always grab a fresh, dead-empty block from your freelists.  If you are doing parallel DML, the Append mode is the default and you don't need to specify an APPEND hint. 
  • Disable/drop indexes:  It's far faster to rebuild indexes after the data load, all at-once. Also indexes will rebuild cleaner, and with less I/O if they reside in a tablespace with a large block size.

REF:Oracle Tuning- The Definitive Reference Second Edition


本文转自海天一鸥博客园博客,原文链接:http://www.cnblogs.com/sgsoft/archive/2011/01/06/1927053.html,如需转载请自行联系原作者

相关文章
|
SQL 数据库
sql中update,alter,modify,delete,drop的区别和使用(整理)(转)
关于update和alter: 百度知道上关于update和alter有一个很形象的总结: 一个表有很多字段,一个字段里有很多数据。 一个家有很多房间,一个房间里有很多家具。 update是用来将衣柜改成书架的。
1238 0
|
9月前
|
关系型数据库 MySQL 数据库
INSERT IGNORE与INSERT INTO的区别
INSERT IGNORE与INSERT INTO的区别
218 0
|
关系型数据库 MySQL 数据库
mysql字符集,insert,update,delete,select
发现有错误:数据太长了。//查看数据库的所有编码:show variables like 'character%';-----+| character_set_client     | utf8    设置客户端的字符集     || character_set_connection | utf8    设置连接的字符集     || character_set_database   | ut
1127 0
|
关系型数据库 PostgreSQL
PostgreSQL merge insert(upsert/insert into on conflict) 如何区分数据是INSERT还是UPDATE
标签 PostgreSQL , merge insert , upsert , insert into on conflict , 区分 insert update , xmin , xmax 背景 使用insert into on conflict update语法,可以支持UPSERT的功能,但是到底这条SQL是插入的还是更新的呢?如何判断 通过xmax字段的值是否不为0,可以判断,如果是UPDATE,XMAX里面会填充更新事务号。
2200 0
|
SQL 存储
Merge(在一条语句中使用Insert,Update,Delete) 对两个表进行同步数据
SQL Server 2008提供了一个增强的SQL命令Merge,用法参看MSDN:http://msdn.microsoft.com/zh-cn/library/bb510625.aspx 功能:根据与源表联接的结果,对目标表执行插入、更新或删除操作。
919 0
|
关系型数据库 MySQL 索引
浅谈create table as 和 insert into select 复制表遇到的问题
之前做一次表压缩测试,在准备原表时需要数据量比较大的表,通过insert into select 的方式将几个表的数据复制到一个表,产生的一些问题~
3288 0
|
9月前
|
SQL
DML(insert与delete)
DML(insert与delete)
55 0
|
存储 C#
T-SQL笔记2:INSERT、UPDATE和DELETE
T-SQL笔记2:INSERT、UPDATE和DELETE 本章摘要 1:显示向一个IDENTITY列插入值 2:在表中插入拥有UNIQUEIDENTIFIER列的行 3:使用INSERT……SELECT语句插入多行 4:调用存储过程插入数据 5:根据FROM和WHERE字句更新行 6:更新大值数据类型的列 7:使用OPENROWSET和BULK插入或更新图片文件 8:DELETE 9:截断表 10:使用TOP分块修改数据   1:显示向一个IDENTITY列插入值      IDENTITY通常用作代理键(代理键是指由数据库生成的唯一的主键)。
1057 0

热门文章

最新文章