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 9i和10g在create index和rebuild index的統計資訊的區別OracleIndexRebuild
- 聊聊索引Index Rebuild和Rebuild Online(下)索引IndexRebuild
- 聊聊索引Index Rebuild和Rebuild Online(上)索引IndexRebuild
- create index , rebuild index troubleshooting 索引故障解決IndexRebuild索引
- 10g在create index時就有索引統計資訊,9i 沒有Index索引
- Sqlserver表統計資訊丟失問題SQLServer
- ORACLE中index的rebuildOracleIndexRebuild
- Default behavior of create & rebuild index in 10G (zt)RebuildIndex
- ORACLE表統計資訊與列統計資訊、索引統計資訊Oracle索引
- Oracle alter index rebuild 說明OracleIndexRebuild
- 加快建立索引(create / rebuild index) 的幾點索引RebuildIndex
- Oracle表table與索引index的分析及索引重建及統計資訊匯入匯出Oracle索引Index
- oracle10g_alter index rebuild_online_重構索引OracleIndexRebuild索引
- rebuild indexRebuildIndex
- index rebuildIndexRebuild
- Oracle index索引塊分裂split資訊彙總OracleIndex索引
- Oracle 10g DG 主庫丟失歸檔Oracle 10g
- rebuild index 排序RebuildIndex排序
- sybase rebuild indexRebuildIndex
- 重建索引index rebuild online vs offline vs index coalesce vs index shrik space索引IndexRebuild
- oracle索引分類rebuild案例集Oracle索引Rebuild
- oracle 建立或重建索引時收集統計資訊不自動收集(_optimizer_compute_index_stats)Oracle索引Index
- 索引rebuild online失敗後處理索引Rebuild
- oracle index索引原理OracleIndex索引
- Oracle效能優化之“少做事”(rebuild index)Oracle優化RebuildIndex
- Oracle什麼情況下需要rebuild indexOracleRebuildIndex
- Index rebuild --case 1IndexRebuild
- alter index rebuild 與 rebuild onlineIndexRebuild
- alter index rebuild與index_statsIndexRebuild
- oracle 更新丟失Oracle
- Oracle全部索引丟失導致的效率問題處理Oracle索引
- Index Online RebuildIndexRebuild
- 【STAT】Oracle 表統計資訊被鎖,如何建立索引Oracle索引
- Oracle 10g/11g 統計資訊相關Oracle 10g
- WindowsXP系統還原點丟失怎麼辦Windows
- 【羅玄】從鎖的角度看rebuild index online和rebuild indexRebuildIndex
- 【統計資訊】Oracle統計資訊Oracle
- MSSQL Rebuild(重建)索引SQLRebuild索引