檢視統計資訊 指令碼

2021-06-19 09:51:52 字數 1913 閱讀 3508

我們要去 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';

檢視索引的統計資訊

drop table t11 插入10萬條,c1資料分布均勻 create table t11 as select level c1,level c2 from dual connect by level 100000 插入2萬條c1 100,使該值數量很大,造成c1分布不均勻 insert int...

檢視Oracle中表的統計資訊

oracle資料庫在執行sql語句的時候,會根據統計資訊計算怎樣執行效能更優,當執行效能比自己想象的慢時,就有可能是統計資訊不新導致,檢視統計資訊常用的方式有如下三種 1 檢視當前使用者下的統計資訊 select from user tab statistics t where t.table na...

使用shell指令碼統計日誌資訊

寫乙個完整的指令碼 shell python 統計各個 ip 錯誤日誌 error 的次數並按錯誤數由高到低輸出統計情況 上面例子log 的輸出結果如下 ip error cnt 118.124.94.110 3 118.124.94.173 2 118.124.94.27 1 118.124.94...