Oracle索引的管理

來源:互聯網
上載者:User

Oracle索引的管理

前言:資料庫運行了一段時間之後,由於頻繁的進行了增刪改,索引就會產生片段,片段多了自然而然的就會影響查詢的效率。通過Oracle提供的一些管理檢視和工具就可以分析出資料庫的哪些索引由於片段太多需要進行重建;

一、尋找資料庫比較佔用空間的索引

需要根據業務設定搜尋的條件,索引大小大於特定值,索引的層數大於1的索引

Select a.index_name,a.table_name,a.blevel,B.BLOCKS*8/1024 MB,b.bytes

from dba_indexes a,dba_segments b

Where a.index_name=b.segment_name and a.owner=b.owner and b.segment_type='INDEX'

And a.blevel>1 and B.BLOCKS*8/1024>'&B'

And b.tablespace_name='&A';

二、進行索引的分析

2.1 標準的SQL語句如下:

analyze index index_name validate structure;

例如:schemas:ekpj

table_name:I_SYS_WF_HISTO_PROCESS_ID1

指令碼:analyze index ekpj. I_SYS_WF_HISTO_PROCESS_ID1 validate structure; 

2.2 查看分析結果: 

select name,height, del_lf_rows, lf_rows,

round((del_lf_rows/(lf_rows+0.0000000001))*100) "Frag Percent" from

index_stats;
 

當Frag Percent大於10的時候,即可對索引進行重建;

三、索引重建的指令碼 

ALTER INDEX index_name

REBUILD

NOCOMPRESS

NOPARALLEL

NOLOGGING

TABLESPACE USERS

STORAGE (

INITIAL 38M

NEXT 1M

)

ONLINE; 

總結:
•需要通過業務瞭解哪些表會頻繁的進行增刪改,因為索引片段產生的原因是由於增刪改操作導致的,知道了這些操作將事半功倍;
•進行索引重建必須放在業務的空閑期操作,避免影響業務的正常操作;
•建議每個月進行以上的操作;

由Oracle索引來理解ArcSDE索引

Oracle索引技術之如何建立最佳索引

Oracle索引列NULL值引發執行計畫該表的測試樣本

Oracle索引 主鍵影響查詢速度

Oracle索引掃描

相關文章

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.