查看统计信息_脚本
2013-11-26 22:31
323 查看
我们要去 check 为啥过期了
----看一下 为啥 统计信息过期了,简化了,自己考虑复杂情况 ----
select *
from all_tab_modifications
where table_owner in (select object_owner from plan_table)
and table_name in (select object_name from plan_table )
and (inserts > 0 or updates > 0 or deletes > 0)
order by 5 desc,6 desc ,7 desc;
select owner,
table_name,
partition_name,
subpartition_name,
stats_update_time,
stats_update_time - lag(stats_update_time, 1, null) over(partition by owner, table_name order by stats_update_time) interval
from DBA_TAB_STATS_HISTORY
where owner = 'SCOTT'
and table_name = 'TEST'
order by owner, table_name, stats_update_time desc;
这个脚本 会检查 统计信息 收集的 时间间隔
explain plan for select * from test where owner='SCOTT';
---检查过期了没----
exec dbms_stats.flush_database_monitoring_info;
with tab as
(select object_name
from plan_table
where object_type = 'TABLE'
union
select table_name
from dba_indexes
where owner in (select object_owner from plan_table)
and index_name in (select object_name from plan_table)),
owner as
(select object_owner
from plan_table
where object_type = 'TABLE'
union
select table_owner
from dba_indexes
where owner in (select object_owner from plan_table)
and index_name in (select object_name from plan_table))
select owner, table_name name, object_type, stale_stats, last_analyzed
from dba_tab_statistics
where table_name in (select object_name from tab)
and owner in (select object_owner from owner)
and (stale_stats = 'YES' or last_analyzed is null);
select owner, table_name name, object_type, stale_stats, last_analyzed
from dba_tab_statistics
where table_name='TEST';
----看一下 为啥 统计信息过期了,简化了,自己考虑复杂情况 ----
select *
from all_tab_modifications
where table_owner in (select object_owner from plan_table)
and table_name in (select object_name from plan_table )
and (inserts > 0 or updates > 0 or deletes > 0)
order by 5 desc,6 desc ,7 desc;
select owner,
table_name,
partition_name,
subpartition_name,
stats_update_time,
stats_update_time - lag(stats_update_time, 1, null) over(partition by owner, table_name order by stats_update_time) interval
from DBA_TAB_STATS_HISTORY
where owner = 'SCOTT'
and table_name = 'TEST'
order by owner, table_name, stats_update_time desc;
这个脚本 会检查 统计信息 收集的 时间间隔
explain plan for select * from test where owner='SCOTT';
---检查过期了没----
exec dbms_stats.flush_database_monitoring_info;
with tab as
(select object_name
from plan_table
where object_type = 'TABLE'
union
select table_name
from dba_indexes
where owner in (select object_owner from plan_table)
and index_name in (select object_name from plan_table)),
owner as
(select object_owner
from plan_table
where object_type = 'TABLE'
union
select table_owner
from dba_indexes
where owner in (select object_owner from plan_table)
and index_name in (select object_name from plan_table))
select owner, table_name name, object_type, stale_stats, last_analyzed
from dba_tab_statistics
where table_name in (select object_name from tab)
and owner in (select object_owner from owner)
and (stale_stats = 'YES' or last_analyzed is null);
select owner, table_name name, object_type, stale_stats, last_analyzed
from dba_tab_statistics
where table_name='TEST';
相关文章推荐
- Oracle查看表中每个字段的统计信息脚本
- 查看统计信息脚本
- 查看统计信息脚本
- Oracle 查看 session 当前统计信息 脚本 说明
- 利用Linux脚本+命令查看线程统计信息
- Oracle 查看 session 当前统计信息 脚本 说明
- Oracle 查看 session 当前统计信息 脚本 说明
- Oracle 查看 session 当前统计信息 脚本 说明
- Oracle 查看 session 当前统计信息 脚本 说明
- 如何查看服务器RAID卡信息的SHELL脚本和命令介绍
- Linux Shell脚本查看NUMA信息
- 如何查看表和索引的统计信息
- 对Guava Cache的封装和使用(包括一个管理页面实现了查看统计信息、情况、查看记录等)
- Oracle 判断 并 手动收集 统计信息 脚本
- 测试Nginx对PHP的解析功能--查看PHP安装配置以及功能列表统计信息
- Shell脚本查看apk签名信息
- Trafodion showstats查看表的统计信息
- Oracle 查看收集统计信息
- Oracle 查看 Shared Pool 信息的相关脚本
- 收集统计信息脚本