Oracle 10g rebuild index,索引原來統計資訊丟失
1、建立測試表及索引
create table t as select * from dba_objects where rownum<=100;
create index ind_t_object_id on t(object_id);
create table tt (id number,name varchar2(30));
insert into tt values(1,'aaa');
insert into tt values(2,'bbb');
insert into tt values(3,'ccc');
commit;
2、檢視建立物件當前的統計資訊
select * from dba_tab_statistics where wner='DBMGR' and table_name='T';
統計資訊為空;
select * from dba_ind_statistics where wner='DBMGR' and index_name='IND_T_OBJECT_ID';
統計資訊存在; rowcnt:100
select * from dba_tab_statistics where wner='DBMGR' and table_name='TT';
統計資訊為空;
3、收集表的統計資訊
begin
dbms_stats.gather_table_stats(ownname => 'DBMGR',tabname => 'T', cascade => true);
end;
4、檢視備份的統計資訊
select * from sys.WRI$_OPTSTAT_tab_HISTORY where obj#=357525 order by savtime desc;
備份正常,備份了一條空的統計資訊;備份記錄中savtime:04-JUL-12 04.56.21.319354 PM +08:00
select * from sys.WRI$_OPTSTAT_IND_HISTORY where obj#=357526 order by savtime desc;
備份正常,備份了一條rowcnt:100,analyzetime:2012/7/4 16:50:50 的統計資訊;備份記錄中savtime:04-JUL-12 04.56.21.495591 PM +08:00
5、檢視兩個物件的資訊
select * from dba_objects where wner='DBMGR' and object_name in ('T','IND_T_OBJECT_ID');
created、last_ddl_time 都是2012/7/4 16:50:50;
6、檢視建立物件當前的統計資訊
select * from dba_tab_statistics where wner='DBMGR' and table_name='T';
統計資訊:num_rows: 100 last_analyzed:2012/7/4 16:56:21
select * from dba_ind_statistics where wner='DBMGR' and index_name='IND_T_OBJECT_ID';
統計資訊:num_rows: 100 last_analyzed:2012/7/4 16:56:21
7、為了便於觀察,刪除表中1條資料,重新收集統計資訊,檢視統計資訊
select * from dba_tab_statistics where wner='DBMGR' and table_name='T';
統計資訊:num_rows: 99 last_analyzed:2012/7/4 17:12:44
select * from dba_ind_statistics where wner='DBMGR' and index_name='IND_T_OBJECT_ID';
統計資訊:num_rows: 99 last_analyzed:2012/7/4 17:12:44
7、執行restore,恢復最初的統計資訊
begin
dbms_stats.restore_table_stats(ownname => 'DBMGR',tabname => 'T', AS_OF_TIMESTAMP => '04-JUL-12 04.56.20.495591 PM +08:00');
end;
8、檢視建立物件當前的統計資訊
select * from dba_tab_statistics where wner='DBMGR' and table_name='T';
統計資訊為空; 恢復正確
select * from dba_ind_statistics where wner='DBMGR' and index_name='IND_T_OBJECT_ID';
統計資訊存在; rowcnt:100 last_analyzed:2012/7/4 16:50:50 恢復正確
9、檢視當前備份的索引統計資訊,如圖,都是正確的
10、索引當前統計資訊:rowcnt:100 last_analyzed:2012/7/4 16:50:50;為了便於觀察,再刪除表中10條資料,然後rebuild index
alter index dbmgr.IND_T_OBJECT_ID rebuild online;
我們期望看到新增一條rowcnt為100的統計資訊備份,但是實際新增統計資訊如下,都是空的。
11、當前的統計資訊情況
select * from dba_tab_statistics where wner='DBMGR' and table_name='T';
統計資訊為空;
select * from dba_ind_statistics where wner='DBMGR' and index_name='IND_T_OBJECT_ID';
統計資訊存在; rowcnt:89 last_analyzed:2012/7/4 18:20:41,rebuild index更新了統計資訊
12、嘗試恢復索引統計資訊
begin
dbms_stats.restore_table_stats(ownname => 'DBMGR',tabname => 'T', AS_OF_TIMESTAMP => ' 04-JUL-12 06.20.40.126087 PM +08:00');
end;
13、檢視當前的統計資訊情況
select * from dba_tab_statistics where wner='DBMGR' and table_name='T';
統計資訊為空;
select * from dba_ind_statistics where wner='DBMGR' and index_name='IND_T_OBJECT_ID';
統計資訊為空;索引統計資訊無法恢復到04-JUL-12 06.20.41.126087 PM +08:00 備份前的統計資訊;
=============================================================================================
補充測試:
再刪除10條資料,
begin
dbms_stats.gather_table_stats(ownname => 'DBMGR',tabname => 'T', cascade => true);
end;
select * from dba_tab_statistics where wner='DBMGR' and table_name='T';
統計資訊:num_rows: 79 last_analyzed:2012/7/4 18:31:17
select * from dba_ind_statistics where wner='DBMGR' and index_name='IND_T_OBJECT_ID';
統計資訊:num_rows: 79 last_analyzed:2012/7/4 18:31:18
索引備份的統計資訊:
再刪除10條資料
alter index dbmgr.IND_T_OBJECT_ID rebuild online;
期望看到新增一條rowcnt為79的統計資訊備份,索引新的統計資訊變為num_rows:69,last_analyzed:2012/7/4 18:37:51
結果備份了一條空統計資訊:
執行恢復
begin
dbms_stats.restore_table_stats(ownname => 'DBMGR',tabname => 'T', AS_OF_TIMESTAMP => ' 04-JUL-12 06.35.30.958529 PM +08:00');
end;
索引統計資訊被恢復為空了,無法在恢復出num_rows:79 last_analyzed:2012/7/4 18:31:18的統計資訊;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/11411056/viewspace-734586/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE表統計資訊與列統計資訊、索引統計資訊Oracle索引
- 【STAT】Oracle 表統計資訊被鎖,如何建立索引Oracle索引
- 【統計資訊】Oracle統計資訊Oracle
- MSSQL Rebuild(重建)索引SQLRebuild索引
- Oracle資料庫中的不可見索引 invisible indexOracle資料庫索引Index
- 【INDEX】Oracle 索引常見知識梳理IndexOracle索引
- Oracle vs PG 索引資訊Oracle索引
- Oracle 10g(10.1.0.2)中的OPTIMIZER_INDEX_COST_ADJ(轉)Oracle 10gIndex
- Oracle收集統計資訊Oracle
- 【統計資訊】Oracle常用的收集統計資訊方式Oracle
- 【INDEX】Oracle分割槽索引技術詳解IndexOracle索引
- Oracle中的虛擬列索引-nosegment indexOracle索引Index
- Oracle Redo丟失恢復方案Oracle
- Oracle 統計資訊介紹Oracle
- 修改oracle 的統計資訊Oracle
- 【TUNE_ORACLE】檢視錶,列和索引的統計資訊SQL參考Oracle索引SQL
- RabbitMQ防止訊息丟失MQ
- 【統計資訊】如何備份和還原統計資訊
- SQL優化之統計資訊和索引SQL優化索引
- index_oracle索引梳理系列及分割槽表梳理IndexOracle索引
- 【INDEX】Oracle19c 自動索引技術初探IndexOracle索引
- Oracle閃回功能恢復偶然丟失的資料(轉)Oracle
- MySQL中Innodb如何計算索引的統計資訊?MySql索引
- INDEX REBUILD和INDEX REORGANIZE和UPDATE STATISTICS是否涉及Sch-M的案例分析IndexRebuild
- 北亞資料恢復-WINDOWS還原系統後原分割槽丟失的資料恢復方案資料恢復Windows
- Oracle索引塊分裂split資訊彙總Oracle索引
- [20180525]丟失審計.txt
- oracle 統計資訊檢視與收集Oracle
- 【STATS】Oracle遷移表統計資訊Oracle
- 【SCRIPT】Oracle統計資訊相關SQLOracleSQL
- update表中index索引列對原索引條目做什麼操作?Index索引
- Oracle impdp遷移資料後主鍵丟失故障處理Oracle
- [統計資訊系列7] Oracle 11g的自動統計資訊收集Oracle
- Elasticsearch之索引模板index template與索引別名index aliasElasticsearch索引Index
- 驗證Oracle 10g線上整理碎片索引是否失效過程Oracle 10g索引
- IBM 伺服器raid卡資訊丟失資料恢復IBM伺服器AI資料恢復
- 【ASK_ORACLE】Oracle如何恢復舊的統計資訊Oracle
- MySQL索引統計資訊更新相關的引數MySql索引
- Oracle 19c中的自動索引(DBMS_AUTO_INDEX)Oracle索引Index