自动化维护任务 – Automated Maintenance Task

转自:http://os2ora.com/automated-maintenance-task/

这是11g引入的一套新的自动化机制。Oracle的官方文档大而全,不过想理清楚里面的来龙去脉可不是一件容易的事情。

不过下面几点知识要点是应该记住的。
1. Oracle有三个已定义好的automated maintenance tasks.

  1. Automatic Optimizer Statistics Collection—用于收集各种数据库对象的统计信息。这里又有三种模式:
    • ‘ALL’ – Statistics are collected for all objects in the system
    • ‘ORACLE’ – Statistics are collected for all Oracle owned objects
    • ‘AUTO’ – Oracle decides for which objects to collect statistics
    • 可以通过以下API进行设置
            DBMS_STATS.SET_GLOBAL_PREFS (
              pname VARCHAR2,
              pval VARCHAR2);

        pname为”AUTOSTATS_TARGET”,pval为以上三个值之一。

  2. Automatic Segment Advisor—Identifies segments that have space available for reclamation, and makes recommendations on how to defragment those segments. You can also run the Segment Advisor manually to obtain more up-to-the-minute recommendations or to obtain recommendations on segments that the Automatic Segment Advisor did not examine for possible space reclamation.
  3. Automatic SQL Tuning Advisor—Examines the performance of high-load SQL statements, and makes recommendations on how to tune those statements. You can configure this advisor to automatically implement SQL profile recommendations.

2. 这些automated maintenace tasks在maintenance windows里得到执行。同样,Oracle已经定义好的7个windows,对应每周的每一天。周一到周五是从22:00到次日的02:00,周六和周日是从06:00到次日的02:00。

3. 如果不想这些automated maintenance tasks在一些windows里不被执行,或者完全不希望执行这些tasks。可以通过下面的API。

DBMS_AUTO_TASK_ADMIN.DISABLE(...)

4. 对于maintenance windows,系统会切换到相应的resource plan。如果你不想你原来的resource plan 被切换掉的话,记得在你设置resource plan时,在resource plan的名字前面加上force:。如下面所示:

ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'FORCE:mydb_plan';

自动化是个好东西,不过这建立上你正确理解了它们的基础上,要不有时就会出现莫名其妙的结果了。

举个简单的例子:如果你在某个时候truncate了一个表,之后重新加载了海量的数据,如果在你truncate后,加载数据之前,收集统计信息的任务启动了,那么它会把这个表的统计信息更新为空表的数据。于是,你的很多涉及到这个表的SQL语句就会莫名其妙的慢下来甚至于执行不完了,原因就在于统计信息的错误变化(海量->空),导致CBO对很多语句从原来的索引访问者变成了致命的全表扫描了。

转载于:https://www.cnblogs.com/cnmarkao/p/4642339.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值