[Oracle 工程师手记]Expdp 导出时速度慢的解决思路
返回 Oracle 索引页
客户问到,当进行数据导出(expdp) 时速度慢,询问解决的方法。
通过查询,看到在长时间等待的session 中,DataPump 的子进程 DW00,它的 LAST_CALL_ET 很大(7小时以上)
set lines 200 pages 2000 col username for a10 col machine for a10 col SPID for a10 col program for a10 col event for a10 select /*+rule*/ s.sid,s.serial#,s.username,p.spid,s.machine,s.program,s.sql_id,s.prev_sql_id,s.event,s.last_call_et,s.blocking_session from v$session s,v$process p where s.status='ACTIVE' and wait_class#<>6 and p.addr=s.paddr order by last_call_et desc; SID SERIAL# USERNAME SPID MACHINE PROGRAM SQL_ID PREV_SQL_ID EVENT LAST_CALL_ET BLOCKING_SESSION ---------- ---------- ---------- ---------- ---------- ---------- ------------- ------------- ---------- ------------ ---------------- 2230 32101 SYS 18546702 TET_LTDB1 oracle@TET_LTDB1 fa2h41tsd6y3r adsr5kj4p2357 db file sequential 27058 (DW00) read ......
接下来,用上面查到的 sql_id,在 v$sql 中,可以看到该SQL语句在执行怎样的操作:
set linesize 200 pages 1000 set long 9999999 set lines 1000 pages 1000 col sql_fulltext for a1500 select sql_fulltext from v$sql where sql_id='&sql_id'; Enter value for sql_id: fa2h41tsd6y3r old 1: select sql_fulltext from v$sql where sql_id='&sql_id' new 1: select sql_fulltext from v$sql where sql_id='fa2h41tsd6y3r' SQL_FULLTEXT -------------------- SELECT /*+all_rows*/ SYS_XMLGEN(VALUE(KU$), XMLFORMAT.createFormat2('INDEX_T', '7')), KU$.OBJ_NUM ,KU$.ANC_OBJ.NAME ,KU$.ANC_OBJ.OWNER_NAME , KU$.ANC_OBJ.TYPE_NAME ,KU$.SCHEMA_OBJ.NAME ,KU$.SCHEMA_OBJ.NAME ,'INDEX' ,KU$.PROPERTY ,KU$.SCHEMA_OBJ.OWNER_NAME ,KU$.TS_NAME , to_char(KU$.TYPE_NUM) ,decode(cardinality(KU$.COL_LIST),0,'1','0') FROM SYS.KU$_INDEX_VIEW KU$ WHERE NOT KU$.FOR_PKOID=1 AND NOT KU$.FOR_REFPAR=1 AND NOT BITAND(KU$.BASE_OBJ.FLAGS,128)!=0 AND NOT BITAND(KU$.SCHEMA_OBJ.FLAGS,4)=4 AND KU$.BASE_OBJ_NUM IN (SELECT * FROM TABLE(DBMS_METADATA.FETCH_OBJNUMS(200001))) AND KU$.BASE_OBJ.OWNER_NAME LIKE '%' AND KU$.SCHEMA_OBJ.OWNER_NAME LIKE '%' AND KU$.TYPE_NUM =2 ORDER BY KU$.SCHEMA_OBJ.OWNER_NUM, KU$.SCHEMA_OBJ.DATAOBJ_NUM ......
可以发现,它正在访问数据库字典表 SYS.KU$_INDEX_VIEW KU$。
可以考虑收集与有关数据库字典表的统计情报:
connect / as sysdba exec dbms_stats.gather_dictionary_stats; exec dbms_stats.lock_table_stats (null,'X$KCCLH'); exec dbms_stats.gather_fixed_objects_stats;
这样可以使得执行时获得更合理的执行计划。
又因 expdp 会使用 stream_pool,也可以考虑,增加其大小。
返回 Oracle 索引页