您的位置:首页 > 数据库 > Oracle

Oracle技术之10204 AWR导入性能问题

2013-07-01 10:48 267 查看
测试发现10g的AWR在导入大数据量的SNAP数据时,性能明显下降。

一个不到2G的AWR导出文件,利用AWR导入到目标数据库中,居然用时超过了5个小时。
bash-2.03$ sqlplus / as sysdba
SQL*Plus: Release10.2.0.4.0 - Production on星期五11月19 08:42:16 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

连接到:
Oracle Database10gEnterprise Edition Release10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> @?/rdbms/admin/awrload
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Disclaimer: This SQL/Plus script. should only be called under
the guidance of Oracle Support.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
AWR LOAD
~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ This script. will load the AWR data from a dump file. The ~
~ script. will prompt users for the following information: ~
~ (1) name of directory object ~
~ (2) name of dump file ~
~ (3) staging schema name to load AWR data into ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Specify the Directory Name
~~~~~~~~~~~~~~~~~~~~~~~~~~
Directory Name Directory Path
------------------------------ -------------------------------------------------
ADMIN_DIR /data/oracle/product/10.2/database/md/admin
DATA_PUMP_DIR /data/oracle/product/10.2/database/rdbms/log/
D_AWR /data1/awr
ORACLE_OCM_CONFIG_DIR /data/oracle/product/10.2/database/ccr/state
WORK_DIR /data/oracle/product/10.2/database/work
Choose a Directory Name from the list above (case-sensitive).
输入directory_name的值: D_AWR
Using the dump directory: D_AWR
Specify the Name of the Dump File to Load
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please specify the prefix of the dump file (.dmp) to load:
输入file_name的值: awrdat_1_47802
Loading from the file name: awrdat_1_47802.dmp
Staging Schema to Load AWR Snapshot Data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The next step is to create the staging schema
where the AWR snapshot data will be loaded.
After loading the data into the staging schema,
the data will be transferred into the AWR tables
in the SYS schema.

The default staging schema name is AWR_STAGE.
To use this name, press <return> to continue, otherwise enter
an alternative.
输入schema_name的值:
Using the staging schema name: AWR_STAGE
Choose the Default tablespace for the AWR_STAGE user
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Choose the AWR_STAGE users's default tablespace. This is the
tablespace in which the AWR data will be staged.
TABLESPACE_NAME CONTENTS DEFAULT TABLESPACE
------------------------------ --------- ------------------
SYSAUX PERMANENT *
USERS PERMANENT
Pressing <return> will result in the recommended default
tablespace (identified by *) being used.
输入default_tablespace的值: sysaux
Using tablespace SYSAUX as the default tablespace for the AWR_STAGE

Choose the Temporary tablespace for the AWR_STAGE user
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Choose the AWR_STAGE user's temporary tablespace.
TABLESPACE_NAME CONTENTS DEFAULT TEMP TABLESPACE
------------------------------ --------- -----------------------
TEMP TEMPORARY *
Pressing <return> will result in the database's default temporary
tablespace (identified by *) being used.
输入temporary_tablespace的值:
Using tablespace TEMP as the temporary tablespace for AWR_STAGE

... Creating AWR_STAGE user
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Loading the AWR data from the following
| directory/file:
| /data1/awr
| awrdat_1_47802.dmp
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| *** AWR Load Started ...
|
| This operation will take a few moments. The
| progress of the AWR load operation can be
| monitored in the following directory/file:
| /data1/awr
| awrdat_1_47802.log
|
WHERE (DBID) NOT IN (SELECT DBID FROM AWR_STAGE.WRM$_WR_CONTROL)
WHERE (DBID, INSTANCE_NUMBER, STARTUP_TIME) NOT IN (SELECT DBID, INSTANCE_NUMBER, STARTUP_TIME FROM
AWR_STAGE.WRM$_DATABASE_INSTANCE)
WHERE (DBID, SNAP_ID) NOT IN (SELECT DBID, SNAP_ID FROM AWR_STAGE.WRM$_SNAPSHOT)
WHERE (DBID, SNAP_ID) NOT IN (SELECT DBID, SNAP_ID FROM AWR_STAGE.WRM$_SNAP_ERROR)
WHERE (DBID, STAT_ID) NOT IN (SELECT DBID, STAT_ID FROM AWR_STAGE.WRH$_STAT_NAME)
WHERE (DBID, PARAMETER_HASH) NOT IN (SELECT DBID, PARAMETER_HASH FROM AWR_STAGE.WRH$_PARAMETER_NAME)
WHERE (DBID, EVENT_ID) NOT IN (SELECT DBID, EVENT_ID FROM AWR_STAGE.WRH$_EVENT_NAME)
WHERE (DBID, LATCH_HASH) NOT IN (SELECT DBID, LATCH_HASH FROM AWR_STAGE.WRH$_LATCH_NAME)
WHERE (DBID, SNAP_ID) NOT IN (SELECT DBID, SNAP_ID FROM AWR_STAGE.WRH$_FILESTATXS)
WHERE (DBID, SNAP_ID) NOT IN (SELECT DBID, SNAP_ID FROM AWR_STAGE.WRH$_FILESTATXS_BL)
.
.
.
WHERE (DBID, SNAP_ID) NOT IN (SELECT DBID, SNAP_ID FROM AWR_STAGE.WRH$_ACTIVE_SESSION_HISTORY)
WHERE (DBID, SNAP_ID) NOT IN (SELECT DBID, SNAP_ID FROM AWR_STAGE.WRH$_ACTIVE_SESSION_HISTORY_BL)
已成功加载/卸载了主表"SYS"."SYS_IMPORT_FULL_01"
启动"SYS"."SYS_IMPORT_FULL_01":
处理对象类型TABLE_EXPORT/TABLE/TABLE
处理对象类型TABLE_EXPORT/TABLE/TABLE_DATA
. .导入了"AWR_STAGE"."WRH$_SQL_PLAN" 212.1 MB 769266行
. .导入了"AWR_STAGE"."WRH$_SQLTEXT" 114.0 MB 48107行
. .导入了"AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_46936" 155.2 MB 820442行
. .导入了"AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_45248" 139.3 MB 725923行
. .导入了"AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_46552" 135.3 MB 714041行
. .导入了"AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_47664" 124.4 MB 657252行
. .导入了"AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_45440" 112.9 MB 594929行
. .导入了"AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_47280" 110.9 MB 588137行
. .导入了"AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_46359" 98.25 MB 519423行
. .导入了"AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_45713" 69.07 MB 365955行
. .导入了"AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_45906" 68.64 MB 363224行
. .导入了"AWR_STAGE"."WRH$_SYSMETRIC_SUMMARY" 25.81 MB 352755行
.
.
.
. .导入了"AWR_STAGE"."WRR$_CAPTURE_STATS" 0 KB 0行
. .导入了"AWR_STAGE"."WRR$_FILTERS" 0 KB 0行
处理对象类型TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
处理对象类型TABLE_EXPORT/TABLE/COMMENT
处理对象类型TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
作业"SYS"."SYS_IMPORT_FULL_01"已于13:19:40成功完成
Register the DBID: 3944144691
Append Data for AWR_STAGE.WRM$_DATABASE_INSTANCE.
INSERT /*+ APPEND */ INTO SYS.WRM$_DATABASE_INSTANCE (DBID, INSTANCE_NUMBER, STARTUP_TIME, PARALLEL, VERSION,
DB_NAME, INSTANCE_NAME, HOST_NAME, LAST_ASH_SAMPLE_ID) SELECT DBID, INSTANCE_NUMBER, STARTUP_TIME, PARALLEL,
VERSION, DB_NAME, INSTANCE_NAME, HOS
T_NAME, LAST_ASH_SAMPLE_ID FROM AWR_STAGE.WRM$_DATABASE_INSTANCE WHERE (DBID, INSTANCE_NUMBER, STARTUP_TIME)
NOT IN (SELECT DBID, INSTANCE_NUMBER, STARTUP_TIME FROM SYS.WRM$_DATABASE_INSTANCE)
Append Data for AWR_STAGE.WRM$_SNAPSHOT.
INSERT /*+ APPEND */ INTO SYS.WRM$_SNAPSHOT (SNAP_ID, DBID, INSTANCE_NUMBER, STARTUP_TIME,
BEGIN_INTERVAL_TIME, END_INTERVAL_TIME, FLUSH_ELAPSED, SNAP_LEVEL, STATUS, ERROR_COUNT, BL_MOVED, SNAP_FLAG)
SELECT SNAP_ID, DBID, INSTANCE_NUMBER, STARTUP_TIME, BE
GIN_INTERVAL_TIME, END_INTERVAL_TIME, FLUSH_ELAPSED, SNAP_LEVEL, 1, 0, 0, SNAP_FLAG + 2 FROM
AWR_STAGE.WRM$_SNAPSHOT WHERE (DBID, SNAP_ID) NOT IN (SELECT DBID, SNAP_ID FROM SYS.WRM$_SNAPSHOT)
.
.
.
Append Data for AWR_STAGE.WRH$_ACTIVE_SESSION_HISTORY_BL.
INSERT /*+ APPEND */ INTO SYS.WRH$_ACTIVE_SESSION_HISTORY (SNAP_ID, DBID, INSTANCE_NUMBER, SAMPLE_ID,
SAMPLE_TIME, SESSION_ID, SESSION_SERIAL#, USER_ID, SQL_ID, SQL_CHILD_NUMBER, SQL_PLAN_HASH_VALUE,
SERVICE_HASH, SESSION_TYPE, SQL_OPCODE, QC_SESSION_ID,
QC_INSTANCE_ID, CURRENT_OBJ#, CURRENT_FILE#, CURRENT_BLOCK#, SEQ#, EVENT_ID, P1, P2, P3, WAIT_TIME,
TIME_WAITED, PROGRAM, MODULE, ACTION, CLIENT_ID, FORCE_MATCHING_SIGNATURE, BLOCKING_SESSION,
BLOCKING_SESSION_SERIAL#, XID, PLSQL_ENTRY_OBJECT_ID, PLSQL_EN
TRY_SUBPROGRAM_ID, PLSQL_OBJECT_ID, PLSQL_SUBPROGRAM_ID, FLAGS) SELECT SNAP_ID, DBID, INSTANCE_NUMBER,
SAMPLE_ID, SAMPLE_TIME, SESSION_ID, SESSION_SERIAL#, USER_ID, SQL_ID, SQL_CHILD_NUMBER, SQL_PLAN_HASH_VALUE,
SERVICE_HASH, SESSION_TYPE, SQL_OPCODE, QC_
SESSION_ID, QC_INSTANCE_ID, CURRENT_OBJ#, CURRENT_FILE#, CURRENT_BLOCK#, SEQ#, EVENT_ID, P1, P2, P3,
WAIT_TIME, TIME_WAITED, PROGRAM, MODULE, ACTION, CLIENT_ID, FORCE_MATCHING_SIGNATURE, BLOCKING_SESSION,
BLOCKING_SESSION_SERIAL#, XID, PLSQL_ENTRY_OBJECT_
ID, PLSQL_ENTRY_SUBPROGRAM_ID, PLSQL_OBJECT_ID, PLSQL_SUBPROGRAM_ID, FLAGS FROM
AWR_STAGE.WRH$_ACTIVE_SESSION_HISTORY_BL WHERE (DBID, SNAP_ID) NOT IN (SELECT DBID, SNAP_ID FROM
SYS.WRH$_ACTIVE_SESSION_HISTORY)
Append Data for AWR_STAGE.WRM$_SNAP_ERROR.
INSERT /*+ APPEND */ INTO SYS.WRM$_SNAP_ERROR (SNAP_ID, DBID, INSTANCE_NUMBER, TABLE_NAME, ERROR_NUMBER)
SELECT SNAP_ID, DBID, INSTANCE_NUMBER, TABLE_NAME, ERROR_NUMBER FROM AWR_STAGE.WRM$_SNAP_ERROR WHERE (DBID,
SNAP_ID, INSTANCE_NUMBER, TABLE_NAME) NOT
IN (SELECT DBID, SNAP_ID, INSTANCE_NUMBER, TABLE_NAME FROM SYS.WRM$_SNAP_ERROR)
UPDATE SYS.WRM$_SNAPSHOT s1 SET status = 0, error_count = (SELECT count(*) FROM SYS.wrm$_snap_error s2 WHERE
s1.dbid = s2.dbid AND s1.snap_id = s2.snap_id AND s1.instance_number = s2.instance_number) WHERE status =
1 AND BITAND(snap_flag, 2) != 0
AND (dbid, snap_id) IN (SELECT dbid, snap_id FROM AWR_STAGE.WRM$_SNAPSHOT)
Finished MOVE_TO_AWR procedure
... Dropping AWR_STAGE user
End of AWR Load
可以看到在数据泵导入输出之前,多了很多WHERE语句,且在最后Append Data for输出的时候多了很多sql语句,正是这些导致了10204上导入AWR数据性能很差。
而在10203或11.2上执行导入,同样的数据不到一个小时就能完成:
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database10gEnterpriseEdition Release10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Linux: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
SQL> @?/rdbms/admin/awrload.sql
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Disclaimer: This SQL/Plus script. should only be called under
the guidance of Oracle Support.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
AWR LOAD
~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ This script. will load the AWR data from a dump file. The ~
~ script. will prompt users for the following information: ~
~ (1) name of directory object ~
~ (2) name of dump file ~
~ (3) staging schema name to load AWR data into ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Specify the Directory Name
~~~~~~~~~~~~~~~~~~~~~~~~~~
Directory Name Directory Path
------------------------------ -------------------------------------------------
ADMIN_DIR /opt/ora10g/product/10.2.0/db_1/md/admin
DATA_PUMP_DIR /opt/ora10g/product/10.2.0/db_1/rdbms/log/
EXTDIR /home/oracle/script/
TRAN /data/backup
WORK_DIR /opt/ora10g/product/10.2.0/db_1/work
Choose a Directory Name from the list above (case-sensitive).
Enter value for directory_name: DMP_DIR
Using the dump directory: DMP_DIR
Specify the Name of the Dump File to Load
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please specify the prefix of the dump file (.dmp) to load:
Enter value for file_name: awrdat_1_47802
Loading from the file name: awrdat_1_47802.dmp
Staging Schema to Load AWR Snapshot Data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The next step is to create the staging schema
where the AWR snapshot data will be loaded.
After loading the data into the staging schema,
the data will be transferred into the AWR tables
in the SYS schema.

The default staging schema name is AWR_STAGE.
To use this name, press <return> to continue, otherwise enter
an alternative.
Enter value for schema_name:
Using the staging schema name: AWR_STAGE
Choose the Default tablespace for the AWR_STAGE user
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Choose the AWR_STAGE users's default tablespace. This is the
tablespace in which the AWR data will be staged.
TABLESPACE_NAME CONTENTS DEFAULT TABLESPACE
------------------------------ --------- ------------------
BOOKS PERMANENT
NDMAIN PERMANENT
SYSAUX PERMANENT *
TEST PERMANENT
ZJ_LPD PERMANENT
Pressing <return> will result in the recommended default
tablespace (identified by *) being used.
Enter value for default_tablespace: ndmain
Using tablespace NDMAIN as the default tablespace for the AWR_STAGE

Choose the Temporary tablespace for the AWR_STAGE user
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Choose the AWR_STAGE user's temporary tablespace.
TABLESPACE_NAME CONTENTS DEFAULT TEMP TABLESPACE
------------------------------ --------- -----------------------
TEMP TEMPORARY *
Pressing <return> will result in the database's default temporary
tablespace (identified by *) being used.
Enter value for temporary_tablespace:
Using tablespace TEMP as the temporary tablespace for AWR_STAGE

... Creating AWR_STAGE user
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Loading the AWR data from the following
| directory/file:
| /data/backup
| awrdat_1_47802.dmp
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| *** AWR Load Started ...
|
| This operation will take a few moments. The
| progress of the AWR load operation can be
| monitored in the following directory/file:
| /data/backup
| awrdat_1_47802.log
|
Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_FULL_01":
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "AWR_STAGE"."WRH$_SQL_PLAN" 212.1 MB 769266 rows
. . imported "AWR_STAGE"."WRH$_SQLTEXT" 114.0 MB 48107 rows
. . imported "AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_46936" 155.2 MB 820442 rows
. . imported "AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_45248" 139.3 MB 725923 rows
. . imported "AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_46552" 135.3 MB 714041 rows
. . imported "AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_47664" 124.4 MB 657252 rows
. . imported "AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_45440" 112.9 MB 594929 rows
. . imported "AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_47280" 110.9 MB 588137 rows
. . imported "AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_46359" 98.25 MB 519423 rows
. . imported "AWR_STAGE"."WRH$_ACTIVE_SESSION_HISTORY":"WRH$_ACTIVE_3944144691_45713" 69.07 MB 365955 rows
.
.
.
. . imported "AWR_STAGE"."WRR$_CAPTURE_STATS" 0 KB 0 rows
. . imported "AWR_STAGE"."WRR$_FILTERS" 0 KB 0 rows
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/COMMENT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Job "SYS"."SYS_IMPORT_FULL_01" successfully completed at 09:44:25
Register the DBID: 3944144691
Append Data for AWR_STAGE.WRM$_DATABASE_INSTANCE.
Append Data for AWR_STAGE.WRM$_SNAPSHOT.
Append Data for AWR_STAGE.WRH$_STAT_NAME.
Append Data for AWR_STAGE.WRH$_PARAMETER_NAME.
Append Data for AWR_STAGE.WRH$_EVENT_NAME.
Append Data for AWR_STAGE.WRH$_LATCH_NAME.
Append Data for AWR_STAGE.WRH$_FILESTATXS.
.
.
.
Append Data for AWR_STAGE.WRH$_ACTIVE_SESSION_HISTORY_BL.
Append Data for AWR_STAGE.WRM$_SNAP_ERROR.
Finished MOVE_TO_AWR procedure
... Dropping AWR_STAGE user
End of AWR Load
可以看到,在输出中不包括任何WHERE语句,在Append Data for输出的时候也没有包括INSERT语句。正是10204上的增加的这些操作导致了AWR导入效率明显下降。

oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息