exp/imp与expdp/impdp对比及使用中的一些优化事项(三)

2014-11-24 08:49:01 · 作者: · 浏览: 4
rameter when exporting in full, user or table mode (i.e.: when specifying FULL=Y or OWNER=scott or TABLES=scott.emp).
-- 直接路径不能使用在tablespace-mode
The parameter QUERY applies ONLY to conventional path Export. It cannot be specified in a direct path export (DIRECT=Y).
-- 直接路径不支持query 参数。 query 只能在conventional path模式下使用。
In versions of Export prior to 8.1.5, you could not use direct path Export for tables containing objects and LOBs.
-- 如果exp 版本小于8.1.5,不能使用exp 导入有lob字段的biao。 不过现在很少有有8版本的数据库了。 这点可以忽略掉了。
The BUFFER parameter applies ONLY to conventional path Export. It has no effect on a direct path Export. This BUFFER parameter specifies the size (in bytes) of the buffer used to fetch rows. It determines the maximum number of rows in an array, fetched by Export. For direct path Export, use the RECORDLENGTH parameter to specify the size of the buffer that Export uses for writing to the export file.
-- buffer 选项只对conventional path exp有效。 对于直接路径没有影响。 对于直接路径, 应该设置RECORDLENGTH 参数。
The RECORDLENGTH parameter specifies the length (in bytes) of the file record. You can use this parameter to specify the size of the Export I/O buffer (highest value is 64 kb). Changing the RECORDLENGTH parameter affects only the size of data that accumulates before writing to disk. It does not affect the operating system file block size. If you do not define this parameter, it defaults to your platform-dependent value for BUFSIZ (1024 bytes in most cases).
invoking a Direct path Export with a maximum I/O buffer of 64kb can improve the performance of the Export with almost 50%. This can be achieved by specifying the additional Export parameters DIRECT and RECORDLENGTH.
-- 对于直接路径下, RECORDLENGTH参数建议设成64k(65535)。这个值对性能提高比较大。
2.2 IMP
Oracle Import进程需要花比Export进程数倍的时间将数据导入数据库。某些关键时刻,导入是为了应对数据库的紧急故障恢复。为了减少宕机时间,加快导入速度显得至关重要。没有特效办法加速一个大数据量的导入,但我们可以做一些适当的设定以减少整个导入时间。
(1)避免I/O竞争
Import是一个I/O密集的操作,避免I/O竞争可以加快导入速度。如果可能,不要在 系统高峰的时间导入数据,不要在导入数据时运行job等可能竞争系统资源的操作。
(2)增加排序区
Oracle Import进程先导入数据再创建索引,不论INDEXES值设为YES或者NO,主键的索引是一定会创建的。创建索引的时候需要用到排序区,在内存大小不足的时候,使用临时表空间进行磁盘排序,由于磁盘排序效率和内存排序效率相差好几个数量级。增加排序区可以大大提高创建索引的效率,从而加快导入速度。
(3)调整BUFFER选项
Imp参数BUFFER定义了每一次读取导出文件的数据量,设的越大,就越减少Import进程读取数据的次数,从而提高导入效率。BUFFER的大小取决于系统应用、数据库规模,通常来说,设为百兆就足够了。其用法如下:
imp user/pwd fromuser=user1 touser=user2 file=/tmp/imp_db_pipe1 commit=y feedback=10000 buffer=10240000
(4)使用COMMIT=Y选项
COMMIT=Y表示每个数据缓冲满了之后提交一次,而不是导完一张表提交一次。这样会大大减少对系统回滚段等资源的消耗,对顺利完成导入是有益的。
(5)使用INDEXES=N选项
前面谈到增加排序区时,说明Imp进程会先导入数据再创建索引。导入过程中建立用户定义的索引,特别是表上有多个索引或者数据表特别庞大时,需要耗费大量时间。某些情况下,需要以最快的时间导入数据,而索引允许后建,我们就可以使用INDEXES=N 只导入数据不创建索引,从而加快导入速度。
我们可以用INDEXFILE选项生成创建索引的DLL脚本,再手工创建索引。我们也可以用如下的方法导入两次,第一次导入数据,第二次导入索引。其用法如下:
imp user/pwd fromuser=user1 touser=user2 file=/tmp/imp_db_pipe1 commit=y feedback=10000 buffer=10240000 ignore=y rows=y indexes=n
imp user/pwd fromuser=user1 touser=user2 file=/tmp/imp_index_pipe1 commit=y feedback=10000 buffer=10240000 ignore=y rows=n indexes=y
(6)增加 LARGE_POOL_SIZE
如果在init.ora中配置了MTS_SERVICE,MTS_DISPATCHERS等参数,tnsnames.ora中又没有(SERVER=DEDICATED)的配置,那么数据库就使用了共享服务器模式。在MTS模式下,Exp/Imp操作会用到LARGE_POOL,建议调整LARGE_POOL_SIZE到150M。
检查数据库是否在MTS模式下:
SQL>select distinct server from v$session;
如果返回值出现