`
yangsj19870829
  • 浏览: 42330 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Oracle index clustering factor

 
阅读更多

    最近有看到clustering factor,记得之前有看过。现在居然忘了。   还是记录下来。

clustering factor实际是索引列的值在表数据块中的分布情况。相同索引值对应的行分布越紧凑clustering factor值越低,相反相同索引值对应的行分布越分散clustering factor的值越高。

 

    实际上这个因子会影响到TABLE ACCESS BY INDEX ROWID    IO的数量,因子值越小,说明只要少量的IO就可以读取出相应的行(因为因子值越小表示他们可能分布在同一个数据块中),因子值越大,说明需要较多的IO才能读取出相应的行(因为因子值越大表示他们可能散布在不同的数据块中)。    

 

 

Oracle does I/O by blocks. Therefore, the optimizer's decision to use full table scans is influenced by the percentage of blocks accessed, not rows. This is called the index clustering factor. If blocks contain single rows, then rows accessed and blocks accessed are the same.

However, most tables have multiple rows in each block. Consequently, the desired number of rows could be clustered together in a few blocks, or they could be spread out over a larger number of blocks.

Although the clustering factor is a property of the index, the clustering factor actually relates to the spread of similar indexed column values within data blocks in the table. A lower clustering factor indicates that the individual rows are concentrated within fewer blocks in the table. Conversely, a high clustering factor indicates that the individual rows are scattered more randomly across blocks in the table. Therefore, a high clustering factor means that it costs more to use a range scan to fetch rows by rowid, because more blocks in the table need to be visited to return the data. Example 13-3 shows how the clustering factor can affect cost.

Example 13-3 Effects of Clustering Factor on Cost

Assume the following situation:

<!-- class="example" -->
  • There is a table with 9 rows.

  • There is a non-unique index on col1 for table.

  • The c1 column currently stores the values A, B, and C.

  • The table only has three Oracle blocks.

Case 1: The index clustering factor is low for the rows as they are arranged in the following diagram.

                 Block 1       Block 2        Block 3 
                 -------       -------        -------- 
                 A  A  A       B  B  B        C  C  C 

This is because the rows that have the same indexed column values for c1 are located within the same physical blocks in the table. The cost of using a range scan to return all of the rows that have the value A is low, because only one block in the table needs to be read.

Case 2: If the same rows in the table are rearranged so that the index values are scattered across the table blocks (rather than collocated), then the index clustering factor is higher.

                 Block 1       Block 2        Block 3 
                 -------       -------        --------
                 A  B  C       A  B  C        A  B  C

This is because all three blocks in the table must be read in order to retrieve all rows with the value A in col1.

 

 

 

分享到:
评论

相关推荐

    ORACLE索引的认识

    - **核心概念**:在评估索引扫描成本时,Oracle会考虑两个重要因素——聚簇因子(Clustering Factor, CF)和过滤因子(Filtering Factor, FF)。 - **聚簇因子(CF)**:指每个索引块对应的平均数据块数。CF反映了...

    Oracle很详细的讲解

    1.2.11 群集因子(Clustering Factor):它是表中数据在物理上分布与索引顺序是否接近的一个度量值,群集因子越小,索引扫描时访问的数据块就越少。 1.2.12 二元高度(Binary height):它是描述索引树的平衡程度的...

    Oracle Statistic 统计信息

    - **聚集因子 (Clustering factor):** 衡量索引顺序与表中数据实际物理存储顺序的一致性。 4. **系统统计信息 (System statistics):** - **I/O 性能和利用率 (I/O performance and utilization):** 数据库I/O操作...

    关于ORACLE数据库中索引的几点讨论.pdf

    Oracle在评估使用索引的成本时,会考虑两个重要因素:Clustering Factor (CF) 和 Filtering Factor (FF)。 - **CF(聚簇因子)**:它反映了每个索引块对应的平均数据块数。如果索引项在数据块中的分布很均匀,CF值...

    Oracle Index 的三个问题

    Oracle评估成本时涉及两个关键参数:聚集因子(Clustering Factor, CF)和过滤因子(Filtering Factor, FF)。CF表示为获取索引中的每一项,需要读取多少数据块。FF则表示查询结果占总数据量的比例。计算公式大致为...

    Oracle技术大牛整理常见问题.pdf

    *.*.*.** 群集因子(Clustering Factor):群集因子描述了表中行在物理上是如何根据索引排序的。一个低群集因子意味着表中的行按照索引顺序紧密排列,这有利于改善查询性能。 *.*.*.** 二元高度(Binary height):...

    Oracle优化.ppt

    2. 查看索引的统计信息:select ttt.index_name, ttt.num_rows, ttt.distinct_keys, ttt.avg_leaf_blocks_per_key, ttt.clustering_factor from dba_indexes ttt where ttt.owner='SCOTT'; 人工进行统计可以使用...

    Oracle关于重建索引争论的总结

    他们认为,删除的索引条目未被重新利用,导致空间浪费,同时索引的clustering factor(集群因子)可能不再同步,这些问题可以通过重建索引来解决。然而,这些观点并不完全准确,因为Oracle的B树索引具有自我管理的...

    oracle-认证之管理统计信息

    - **指标**:叶块数量(LEAF_BLOCKS)、等级(BLEVEL)以及聚簇因子(CLUSTERING_FACTOR)。 - **存储位置**:这些信息存储在`DBA_INDEXES`视图中。 - **作用**:帮助优化器评估使用索引访问的成本。 ##### 4. 系统计统计...

    40个DBA日常维护的SQL脚本

    ROUND(NVL(IND.CLUSTERING_FACTOR, 1) / DECODE(TAB.NUM_ROWS, 0, 1, TAB.NUM_ROWS), 3) * 100 || '%' "CLUSTERING%" FROM USER_TABLES TAB, USER_INDEXES IND WHERE TAB.TABLE_NAME = IND.TABLE_NAME AND TAB....

    索引对SQL执行成本的影响.pdf

    索引扫描的成本计算公式为:Cost=blevel+ceiling(leaf_blocks + branches_blocks) / effective_index_selectivity + ceiling(clustering_factor / effective_table_selectivity)。在这个公式中,blevel代表索引的...

Global site tag (gtag.js) - Google Analytics