- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
6#
发表于 2012-4-9 16:54:05
"一旦表过期,这个动作会引发我们业务系统严重的硬解析。"
Prior to Oracle 10g, automated collection of statistics for objects that had become stale was controlled by the setting of the MONITORING flag on table.
Depending on the MONITORING flag, the GATHER_STATS_JOB job collected "GATHER EMPTY" and "GATHER STALE"
on the flagged objects.
Whenever there is 10% change in data in a table, Oracle considers its statistics to be stale.
Up to date statistics are important to generate good execution plans. Automatic statistics collection job using DBMS_STATS
packages depend on the monitoring data to determine when to collect statistics on objects with stale statistics.
Prior to Oracle11g, the staleness threshold is hardcoded at 10%. This means that an object is considered stale if the number of rows inserted,updated or deleted since the last statistics gathering time is more than 10% of the number of rows. There is no way to modify this value prior to Oracle 11g.
Starting with Oracle11g, the staleness threshold can be set using the STALE_PERCENT statistics preference. This can be set globally using DBMS_STATS.SET_GLOBAL_PREFS or at the table level using DBMS_STATS.SET_TABLE_PREFS.
statistics 的stale 并不会导致 当前的statistics 立即失效, 也不会 直接(directly)导致 SQL需要重新硬解析。
stale 状态只是告诉 DBMS_STATS package 这些 陈旧统计信息的对象 存在 重新收集 collect statistics的需求。
在10g中 这个stale percent 是hard coding的 为10%, 在11g中可以通过 STALE_PERCENT来定义。
stale 的statistics 不代表这个statistics是失效的invalid的, 不代表相关的SQL 就一定需要再次hard parse 。
反而某些DDL操作会导致 statistics直接invalid 失效, 例如分区表 split partition时 相关分区的统计信息必须失效,即使你尝试lock 这些statistics也不能避免这种失效, 这也将导致 SQL cursor 的 hard reparse 。
可以通过 设置 [size=-1]STATISTICS_LEVEL 为BASIC来 disable 禁用SMON 更新 [size=-1]DBA_TAB_MODIFICATIONS视图相关的基表 详见 了解你所不知道的SMON功能(九):维护MON_MODS$字典基表 http://www.oracledatabase12g.com ... stics-mon-mods.html
但是使用BASIC的 [size=-1]STATISTICS_LEVEL 会导致 AWR、ASH、ADDM、ASMM等10g以后的特性不可用
|
|