oracle查看索引是否生效,oracle表分析效果怎么看,Oracle 索引與表分析幾種方法

 2023-10-20 阅读 19 评论 0

摘要:分析表與索引有幾種方法,現在列舉出來參考下。1.分析表與索引(analyze 不會重建索引)oracle查看索引是否生效。analyze table tablename compute statistics等同于 analyze table tablename compute statistics for table for all indexes for all columnsfor table 的

分析表與索引有幾種方法,現在列舉出來參考下。

1.分析表與索引(analyze 不會重建索引)

oracle查看索引是否生效。analyze table tablename compute statistics

等同于 analyze table tablename compute statistics for table for all indexes for all columns

for table 的統計信息存在于視圖:user_tables 、all_tables、dba_tables

oracle 表分析、for all indexes 的統計信息存在于視圖: user_indexes 、all_indexes、dba_indexes

for all columns 的統計信息存在于視圖:user_tab_columns、all_tab_columns、dba_tab_columns

注:分析表與索引見 AnalyzeAllTable存儲過程

oracle12514,2、一般來講可以采用以下三種方式來手工分析索引。

analyze index idx_t validate structure:

analyze index idx_t compute statistics:

oracle索引類型,analyze index idx_t estimate statistics sample 10 percent

1)analyze index idx_t validate structure:

這段分析語句是用來分析索引的block中是否有壞塊兒,那么根據分析我們可以得到索引的結構數據,這些數據會保留到

index_stats中,來判斷這個索引是否需要rebuild. 需要注意的是這樣的分析是不會收集索引的統計信息的。

2)validate structure有二種模式: online, offline, 一般來講默認的方式是offline。

當以offline的模式analyze索引時,會對table加一個表級共享鎖,對目前table的一些實時DMl操作會產生一定的影響。

而以online模式分析時候,則不會加任何lock,但在index_stats中是看不到任何信息的。

3)analyze index idx_t compute statistics:

用來統計索引的統計信息(全分析),主要為CBO服務。

4)analyze index idx_t estimate statistics sample 10 percent

主要是用來指定比例進行抽樣分析,也是為CBO服務. 例中是抽樣10%

3.重建索引

alter index index_name rebuild tablespace tablespace_name

alter index index_name rebuild tablespace tablespace_name 加入表空間名,會將指定的索引移動到指定的表空間當中。

注:

analyze 操作只是統計信息,并將統計信息存放起來供日后分析SQL使用,不進行重建之類的具體實施性操作,因此要重建索引的話

還是要用 alter index index_name rebuild

相關閱讀:

0b1331709591d260c1c78e86d0c51c18.png

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/4/152363.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息