根据Oracle的文档的描述,数据泵采用不同的方式导出导入,性能也会有明显的差别,这次正好有机会测试一下,迁移表空间、直接路径、外部表方式,以及数据库链方式导出、导入的性能差异。
这篇测试直接路径导出、导入方式。
首先清除上一篇文章中导入的用户和表空间,并重新建立测试用户和表空间。
SQL> DROP USER TJSQ_NDMAIN CASCADE;
User dropped.
SQL> DROP USER TJSQ_TRADE CASCADE;
User dropped.
SQL> DROP USER TJSQ_GOV CASCADE;
User dropped.
SQL> DROP USER TJSQ_NDMAIN_OPER CASCADE;
User dropped.
SQL> DROP USER TJSQ_TRADE_OPER CASCADE;
User dropped.
SQL> DROP TABLESPACE TJSQ INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
SQL> DROP TABLESPACE TJSQ_TMP INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
下面重新创建用户,并设置权限:
SQL> CREATE USER TJSQ_NDMAIN IDENTIFIED BY TJSQ_NDMAIN;
User created.
SQL> CREATE USER TJSQ_TRADE IDENTIFIED BY TJSQ_TRADE;
User created.
SQL> CREATE USER TJSQ_GOV IDENTIFIED BY TJSQ_GOV;
User created.
SQL> CREATE USER TJSQ_NDMAIN_OPER IDENTIFIED BY TJSQ_NDMAIN_OPER;
User created.
SQL> CREATE USER TJSQ_TRADE_OPER IDENTIFIED BY TJSQ_TRADE_OPER;
User created.
SQL> GRANT CONNECT TO TJSQ_GOV;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_GOV;
Grant succeeded.
SQL> GRANT CONNECT TO TJSQ_NDMAIN;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_NDMAIN;
Grant succeeded.
SQL> GRANT CONNECT TO TJSQ_NDMAIN_OPER;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_NDMAIN_OPER;
Grant succeeded.
SQL> GRANT CONNECT TO TJSQ_TRADE;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_TRADE;
Grant succeeded.
SQL> GRANT CONNECT TO TJSQ_TRADE_OPER;
Grant succeeded.
SQL> GRANT RESOURCE TO TJSQ_TRADE_OPER;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_GOV;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_NDMAIN;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_NDMAIN_OPER;
Grant succeeded.
SQL> GRANT CREATE DATABASE LINK TO TJSQ_TRADE;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_TRADE;
Grant succeeded.
SQL> GRANT CREATE SYNONYM TO TJSQ_TRADE_OPER;
Grant succeeded.
表空间的建立以及数据文件初始化的时间需要单独计时:
SQL> SET TIMING ON
SQL> CREATE TABLESPACE TJSQ DATAFILE '/data/oracle/oradata/tjsq/tjsq01.dbf' size20g,
2 '/data/oracle/oradata/tjsq/tjsq02.dbf' size4g;
Tablespace created.
Elapsed: 00:02:07.68
SQL> CREATE TABLESPACE TJSQ_TMP DATAFILE '/data/oracle/oradata/tjsq/tjsq_tmp.dbf' size4g;
Tablespace created.
Elapsed: 00:00:22.19
这个步骤总用时2分30秒。
由于Oracle数据泵的默认导出、导入都是直接路径方式,因此当前的测试不需要进行额外的设置。
下面利用数据泵的导出操作:
[oracle@yans2 dmp]$ expdp system directory=d_dmpdp dumpfile=tjsq_090617.dp schemas=tjsq_trade,tjsq_ndmain,tjsq_gov,tjsq_ndmain_oper,tjsq_trade_oper
Export: Release10.2.0.3.0 - 64bit Production on Wednesday, 17 June, 2009 14:29:04
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Password:
Connected to: Oracle Database10gEnterprise Edition Release10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01": system/******** directory=d_dmpdp dumpfile=tjsq_090617.dp schemas=tjsq_trade,tjsq_ndmain,tjsq_gov,tjsq_ndmain_oper,tjsq_trade_oper
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 9.203 GB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/SEQUENCE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/POST_TABLE_ACTION
Processing object type SCHEMA_EXPORT/TABLE/MATERIALIZED_VIEW_LOG
. . exported "TJSQ_TRADE"."ORD_HIT_COMM" 1.180 GB 1508527 rows
. . exported "TJSQ_TRADE"."CON_ITEM_SEND_IND" 829.2 MB 6212238 rows
. . exported "TJSQ_NDMAIN"."PLT_ORG_PLAT" 77.81 KB 1201 rows
.
.
.
. . exported "TJSQ_TRADE_OPER"."WYP_DISABLE_DUP" 0 KB 0 rows
. . exported "TJSQ_TRADE_OPER"."WYP_DISABLE_HEPING14" 0 KB 0 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
/data/dmp/tjsq_090617.dp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 14:33:53
导出操作一共执行了4分49秒。
下面利用DBMS_FILE_TRANSFER包,将数据泵的导出文件传送到本地:
SQL> SET TIMING ON
SQL> EXEC DBMS_FILE_TRANSFER.GET_FILE('D_DMPDP', 'tjsq_090617.dp', 'NEWDEMO', 'D_DMP', 'tjsq_090617.dp')
PL/SQL procedure successfully completed.
Elapsed: 00:10:22.92
数据泵导出文件传送到远端花费了10分23秒。
最后利用数据库执行导入操作:
[oracle@tj dmp]$ impdp system dumpfile=tjsq_090617.dp directory=d_dmp logfile=tjsq_imp_direct.log
Import: Release10.2.0.3.0 - 64bit Production on星期四, 18 6月, 2009 14:22:51
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Password:
Connected to: Oracle Database10gEnterprise Edition Release10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/******** dumpfile=tjsq_090617.dp directory=d_dmp logfile=tjsq_imp_direct.log
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"TJSQ_TRADE_OPER" already exists
ORA-31684: Object type USER:"TJSQ_NDMAIN_OPER" already exists
ORA-31684: Object type USER:"TJSQ_GOV" already exists
ORA-31684: Object type USER:"TJSQ_NDMAIN" already exists
ORA-31684: Object type USER:"TJSQ_TRADE" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/SEQUENCE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "TJSQ_TRADE"."ORD_HIT_COMM" 1.180 GB 1508527 rows
. . imported "TJSQ_TRADE"."CON_ITEM_SEND_IND" 829.2 MB 6212238 rows
. . imported "TJSQ_NDMAIN"."PLT_ORG_PLAT" 77.81 KB 1201 rows
. . imported "TJSQ_NDMAIN_OPER"."PLT_ORG_PLAT_090324" 508.3 MB 7202314 rows
.
.
.
. . imported "TJSQ_TRADE_OPER"."WYP_DISABLE_DUP" 0 KB 0 rows
. . imported "TJSQ_TRADE_OPER"."WYP_DISABLE_HEPING14" 0 KB 0 rows
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/POST_TABLE_ACTION
Processing object type SCHEMA_EXPORT/TABLE/MATERIALIZED_VIEW_LOG
Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at 14:37:17
导入总共耗时14分26秒。
下面还是更新记录表:
SQL> INSERT INTO T_EXPDP_IMPDP_RECORD VALUES
2 ('DIRECT', 4*60+49, 10*60+23, 14*60+26, 150, 4*60+49+10*60+23+14*60+26+150);
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT * FROM T_EXPDP_IMPDP_RECORD
2 WHERE TYPE = 'DIRECT';
TYPE EXPDP_TIME TRANS_TIME IMPDP_TIME OTHER_TIME TOTAL_TIME
-------------------- ---------- ---------- ---------- ---------- ----------
DIRECT 289 623 866 150 1928
SQL> SELECT ROUND(EXPDP_TIME/TOTAL_TIME*100, 2) EXPDP_RATE,
2 ROUND(TRANS_TIME/TOTAL_TIME*100, 2) TRANS_RATE,
3 ROUND(IMPDP_TIME/TOTAL_TIME*100, 2) IMPDP_RATE,
4 ROUND(OTHER_TIME/TOTAL_TIME*100, 2) OTHER_RATE
5 FROM T_EXPDP_IMPDP_RECORD
6 WHERE TYPE = 'DIRECT';
EXPDP_RATE TRANS_RATE IMPDP_RATE OTHER_RATE
---------- ---------- ---------- ----------
14.99 32.31 44.92 7.78
可以看到,对于当前的环境直接路径导入方式速度更快,只需要32分8秒,就完成了全部的导入工作。
其中导入部分无疑是最耗时的,占了整个比重的45%,导出占了15%,而网络传播占了32%的时间。
oracle视频教程请关注: