Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Krishna.

Asked: November 24, 2015 - 10:18 pm UTC

Last updated: November 25, 2015 - 1:16 pm UTC

Version: 11g

Viewed 10K+ times! This question is

You Asked

Hi Team,


Could you please let me know , How to reduse clustering factor of an index?


Thanks & Regards
Krishna.

and Connor said...

Here's a link to an awesome paper which talks about this topic, plus a number of other ones regarding indexes.

https://richardfoote.files.wordpress.com/2007/12/index-internals-rebuilding-the-truth-ii.pdf

Hope this helps

Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Quick Answer

Hemant K Chitale, November 25, 2015 - 8:28 am UTC

Short Answer : Rebuild the table ORDERed BY the index key and then rebuild all indexes on the table.

Long Answer : Rebuild the table ORDERed BY the index key. Unfortunately, this means that the CLUSTERING_FACTOR of *other* Indexes on the table is changed.

Ask yourself if
(a) you can live with the impact of the change of other indexes CLUSTERING_FACTOR -- e.g. other query execution plans may change
(b) whether it is worth the time (downtime !) and effort to rebuild the table and all it's indexes
(c) whether changes (inserts, updates, deletes) to the data in subsequent days/weeks/months would mean that the CLUSTERING_FACTOR would have to change again each time you update Index Statistics
(d) what if the data that is frequently accessed (most popular) is already really clustered OR will change and uncluster very quickly

A reader, November 25, 2015 - 12:20 pm UTC

select clustering_factor from user_indexes where table_name='AGG_CLAIM_HP'and index_name='IND_CLAIM_HP_CLM_FCTKEY'

clustering_factor
----------------
2992271

select blocks from user_tables where table_name='AGG_CLAIM_HP'

blocks
-------
260505

INDEX_NAME clustering_factor
---------------- ----------
UK_IND_AGG_HP_KEY 3188452
BM_IND_AGG_HP_FACKEY 525
BM_IND_AGG_HP_ORGKEY 296
BM_IND_AGG_HP_DINDKEY 518
IND_CLAIM_HP_CLM_ACCT 3208438
IND_CLAIM_HP_CLM_FCTKEY 3208728

I did

-> reorganized the table
-> rebuild the indexes
-> Gathered statistics of tables and indexes.

Still some indexes clustering factor not nearer to tables blocks.

Please observe above statistics.

Thanks & Regards
Krishna


Connor McDonald
November 25, 2015 - 1:16 pm UTC

I'm assuming you read the whitepaper ?

Because, its fairly evident from it that the way the data is ORDERED within the table is what is going to impact the clustering factor.

of course, if just did 'alter table move' or "export/import' then perhaps you havent changed the order of the data at all...


To Krishna

Rajeshwaran, Jeyabal, November 25, 2015 - 1:34 pm UTC

Because, its fairly evident from it that the way the data is ORDERED within the table is what is going to impact the clustering factor.

Well said Connor.

remember data in the table can be order only in one way (either asc or desc on a/set-of column(s) ). so if ordering is done on column X and index having X on the leading edge will have good clustering factor (CF), but other indexes may not have.

https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1032431852141
https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:677424561114