重建失效索引,失效索引

來源:互聯網
上載者:User

重建失效索引,失效索引

        若資料庫中出現失效索引,使得失效索引所在表相關操作在訪問上本因走索引卻出現大量的全表掃描,這是極其消耗資源的,因此必須對這些失效索引進行線上重建。重建失效索引具體步驟如下:

1. 查詢資料庫中有無失效索引

select owner,table_name,index_name,status,last_analyzed from dba_indexes where status='UNSABLE';
2. 如果有失效的索引,要對索引進行線上重建
alter index mw_app.ind_t_id rebuild online;
3. 查詢索引是否重建好

批註:若查詢出索引狀態為‘VALID’,說明索引已經重建好。

select owner,table_name,index_name,status,last_analyzed from dba_indexes where index_name='IND_T_ID';
4. 重新查詢資料庫中有無失效索引

批註:查詢沒有記錄,說明資料庫裡沒有失效索引,至此失效索引已全部被重建。

select owner,table_name,index_name,status,last_analyzed from dba_indexes where status='UNSABLE';



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.