oracle技术之oracle数据泵不同工作方式性能比较(五)

根据Oracle的文档的描述,数据泵采用不同的方式导出导入,性能也会有明显的差别,这次正好有机会测试一下,迁移表空间、直接路径、外部表方式,以及数据库链方式导出、导入的性能差异。


这篇测试NETWORK_LINK导入方式。






首先清除上一篇文章中导入的用户和表空间,并重新建立测试用户和表空间。


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数据泵的默认导出、导入都是直接路径方式,因此当前的测试不需要进行额外的设置。


使用NETWORK_LINK方式执行导入是否的简单,不需要导出和传送的过程,只需要一个impdp命令就可以完成所有的操作:


[oracle@tj dmp]$ impdp system network_link=NEWDEMO logfile=d_dmp:procedure.log schemas=tjsq_trade,tjsq_ndmain,tjsq_gov,tjsq_ndmain_oper,tjsq_trade_oper


Import: Release10.2.0.3.0 - 64bit Production on星期四, 18 6月, 2009 15:11:06


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_IMPORT_SCHEMA_01":  system/******** network_link=NEWDEMO logfile=d_dmp:procedure.log 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: 10.13 GB


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


. . imported "TJSQ_NDMAIN"."CAT_REGION_MERCHANDISE"     3095660 rows


. . imported "TJSQ_TRADE"."ORD_HIT_COMM"                1508527 rows


. . imported "TJSQ_TRADE"."CON_ITEM_SEND_IND"           6212238 rows


.


.


.


. . imported "TJSQ_TRADE_OPER"."WYP_DISABLE_DUP"              0 rows


. . imported "TJSQ_TRADE_OPER"."WYP_DISABLE_HEPING14"         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_SCHEMA_01" successfully completed at 15:45:42


整个的导入过程用了34分36秒。


同样把数据加入到记录表中:


SQL> INSERT INTO T_EXPDP_IMPDP_RECORD VALUES


 2  ('NETWORK_LINK', 0, 0, 34*60+36, 150, 34*60+36+150);


1 row created.


SQL> COMMIT;


Commit complete.


SQL> SELECT * FROM T_EXPDP_IMPDP_RECORD


 2  WHERE TYPE = 'NETWORK_LINK';


TYPE                 EXPDP_TIME TRANS_TIME IMPDP_TIME OTHER_TIME TOTAL_TIME


-------------------- ---------- ---------- ---------- ---------- ----------


NETWORK_LINK                  0          0       2076        150       2226


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 = 'NETWORK_LINK';


EXPDP_RATE TRANS_RATE IMPDP_RATE OTHER_RATE


---------- ---------- ---------- ----------


        0          0      93.26       6.74


整个NETWORK_LINK导入方式用了37分6秒。


虽然没有必要,但是为了更好的说明问题,下面执行一个NETWORK_LINK方式的导出:


[oracle@tj dmp]$ expdp system network_link=NEWDEMO directory=d_dmp dumpfile=tjsq_network.dp logfile=network_exp.log schemas=tjsq_trade,tjsq_ndmain,tjsq_gov,tjsq_ndmain_oper,tjsq_trade_oper


Export: Release10.2.0.3.0 - 64bit Production on星期四, 18 6月, 2009 16:18:50


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/******** network_link=NEWDEMO directory=d_dmp dumpfile=tjsq_network.dp logfile=network_exp.log 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: 10.13 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_NDMAIN"."CAT_REGION_MERCHANDISE"      1.662 GB 3095660 rows


. . 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_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_network.dp


Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 16:30:46


可以看到NETWORK_LINK方式的导出耗时11分56秒


根据文档NETWORK_LINK方式的速度是最慢的,如果只是对比直接路径导出、外部表导入以及NETWORK_LINK导出方式,显然这种导出方式是最慢的。


同样对比直接路径导入、外部表导入以及NETWORK_LINK导入方式,显然这种导入方式也是最慢的。


但是,NETWORK_LINK的导入可以将导出、传送数据文件和导入集成在一个操作中完成,因此如果单独对比导出或导入时间是不公平的。


对比第三篇文章中的数据就可以发现,NETWORK_LINK导出居然比直接路径导出加上文件传递的速度还快了3分钟左右。这是因为网络传送其实是操作的瓶颈,数据泵生成导出数据的速度要远远快于等待传递的时间,因此导出和IO时间在整个操作中并不明显。


可以看到NETWORK_LINK方式的总体速度仅比直接路径方式慢了5分钟左右。而从操作上将这种方式是最简单的,只需要一个impdp命令,不再需要任何其他的操作了。



oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html


你可能感兴趣的:(oracle,oracle数据泵工作方式性能,oracle数据泵,oracle数据泵工作方式)