重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1964|回复: 0
打印 上一主题 下一主题

[安装] How to Purge WRH$_SQL_PLAN Table in AWR Repository, Occupying Large Space in ...

[复制链接]
跳转到指定楼层
楼主
发表于 2017-3-29 18:11:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
In this Document
Goal
Solution
References

Applies to:
Oracle Database - Enterprise Edition - Version 11.2.0.2 and later
Information in this document applies to any platform.

Goal
How to Purge WRH$_SQL_PLAN table in AWR repository when it is occupying large space in SYSAUX tablespace.
Solution
OPTION 1:

Try executing the dbms_workload_repository.purge_sql_details() as per below:
First count the number in WRH$_SQL_PLAN table.


SQL> select count(*) from sys.wrh$_sql_plan;
SQL> SELECT dbid FROM v$database;
SQL> exec dbms_workload_repository.purge_sql_details(1000, &dbid);               -->>>>> Enter the dbid from above query.
SQL> select count(*) from sys.wrh$_sql_plan;

See if this deletes any rows from the WRH$_SQL_PLAN table. It is needed that you shrink the table and check the table size in the end.

OPTION 2:


Another option is to remove the old wrh$_sql_plan data by running simple "delete from wrh$_sql_plan where snap_id between x and y" manually (delete little by little). After deletion of old records from wrh$_sql_plan table, the table needs to be shrinked.  Then check the table size in the end.
Below SQLs will help in identifying the range of snapshots that can deleted from WRH$_SQL_PLAN.

SQL> select snap_id ,timestamp from  wrh$_sql_plan where snap_id=(select min(snap_id) from  wrh$_sql_plan);
The above query gives the oldest available data in table WRH$_SQL_PLAN.
This data could be older than the last available snapshot in the AWR repository.
SQL> select dbid,SNAP_ID,BEGIN_INTERVAL_TIME,END_INTERVAL_TIME from dba_hist_snapshot where SNAP_ID=&snap_id;The above query gives the oldest available AWR data from dba_hist_snapshot view.
Example for the delete process:
SQL> select min(TIMESTAMP) from wrh$_sql_plan;
MIN(TIMESTAMP)
------------------
06-JUN-08
1 row selected.
SQL> select min(BEGIN_INTERVAL_TIME) from dba_hist_snapshot;
MIN(BEGIN_INTERVAL_TIME)
---------------------------------------------------------------------------
31-JUL-12 12.00.24.903 AM
SQL> select count(*) from sys.wrh$_sql_plan;
COUNT(*)
----------
27147
SQL> delete from wrh$_sql_plan where trunc(TIMESTAMP) < (select min(BEGIN_INTERVAL_TIME) from dba_hist_snapshot);
7449 rows deleted.
SQL> commit;
Commit complete.
SQL> select min(TIMESTAMP) from wrh$_sql_plan;
MIN(TIMESTAMP)
------------------
01-AUG-12
1 row selected.
SQL> select min(BEGIN_INTERVAL_TIME) from dba_hist_snapshot;
MIN(BEGIN_INTERVAL_TIME)
---------------------------------------------------------------------------
31-JUL-12 12.00.24.903 AM
1 row selected.


Delete the older snap_ids from the table to reclaim space in the table. Then shrink the table after delete to reclaim the space.

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-5-18 15:08 , Processed in 0.092884 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表