Sei sulla pagina 1di 2

--If more than 20% of the table is going to be accessed, Oracle will probably do a

full-table scan operation on the table rather than using an index.


--his Index Quality is based on < 5% clustering factor (divide clustering factor by
number of rows)�is Excellent,
< 10% is Good, < 15% is Fair, and anything > 20% is Poor

CF/Rows

select clustering_factor from Dba_indexes where index_name='ADDR_PK';


select blocks from dba_segments where segment_name='ADDR_BTMP_ACCT_IDX';

select index_name, clustering_factor from dba_indexes where table_name='ADDR';

INDEX_NAME CLUSTERING_FACTOR
------------------------------ -----------------
ADDR_BTMP_ACCT_IDX 20323758
ADDR_IND1 27667422
ADDR_PK 7095891

select num_rows_in_block, count(1) blocks


from(select block_no, count(1) num_rows_in_block
from(select dbms_rowid.rowid_block_number(rowid) block_no from outbound.ADDR)
group by block_no) group by num_rows_in_block;

NUM_ROWS_IN_BLOCK BLOCKS
----------------- ----------
13 23678
44 8575
90 2
55 6352
69 7230

select index_name, leaf_blocks, avg_leaf_blocks_per_key, avg_data_blocks_per_key,


clustering_factor, distinct_keys
from dba_indexes
where owner = 'OUTBOUND'
and index_name in ('ADDR_BTMP_ACCT_IDX','ADDR_IND1');

SELECT t.table_name, i.index_name, t.blocks, t.num_rows, i.clustering_factor


FROM dba_tables t, dba_indexes i
WHERE t.table_name = i.table_name AND i.index_name='ADDR_BTMP_ACCT_IDX';

SQL> SELECT t.table_name, i.index_name, t.blocks, t.num_rows, i.clustering_factor


FROM dba_tables t, dba_indexes i
WHERE t.table_name = i.table_name AND i.index_name='ADDR_IND1';

TABLE_NAME INDEX_NAME BLOCKS NUM_ROWS


CLUSTERING_FACTOR
------------------------------ ------------------------------ ---------- ----------
-----------------
ADDR ADDR_IND1 1940862 27366503
27667422

CF/Rows
http://oracle-tech.blogspot.com/2007/09/query-to-determine-clustering-factor.html
--basic concept

http://vineetsoracleblogspot.blogspot.com/2016/04/clustering-factor-and-
tablecachedblocks.html -workout
https://gerardnico.com/db/oracle/clustering_factor

http://db.geeksinsight.com/2013/10/19/12c-database-index-clustering-factor-do-your-
own-math/ -good
http://sateeshv-dbainfo.blogspot.com/2015/08/clustering-factor-demystified-part-
i.html =good
http://sateeshv-dbainfo.blogspot.com/2015/08/clustering-factor-demystified-part-
ii.html
http://sateeshv-dbainfo.blogspot.com/2015/08/clustering-factor-demystified-part-
iii.html

http://raajeshwaran.blogspot.com/2010/09/clustering-factor.html?m=0
https://hemantoracledba.blogspot.com/2008/01/impact-of-clustering-factor.html
-deep conc
http://oracle-tech.blogspot.com/2007/09/query-to-determine-clustering-factor.html
-queries

https://blog.fatalmind.com/2010/03/09/clustering-factor-row-migrations-
victim/index.html --no cf
http://www.peasland.net/2016/02/17/a-tale-of-two-clustering-factors/ --2 CF
http://db.geeksinsight.com/2013/10/19/12c-database-index-clustering-factor-do-your-
own-math/

http://oracleinaction.com/cluster-factor-i/
https://richardfoote.wordpress.com/2013/05/
https://blogs.oracle.com/demantra/demantra-index-cluster-factor-major-update-
performance-impact

SQL> grant execute on sys.dbms_redefinition to hr;


SQL> grant dba to hr;

Summary:
- A good Clustering Factor is equal (or near) to the values of number of blocks of
table.- A bad Clustering Factor is equal (or near) to the number of rows of table.
� A low clustering factor is good and reflects strong clustering.
� A high clustering factor is bad and reflects weak clustering.
� The clustering factor may be lower than the number of blocks if there are empty
blocks in the table below HWM and/or there are many rows that have null values for
the indexed column(s).
� The clustering factor can never be greaterr than the no. of rows in the table.In
my next post, I will demonstrate how to use CTAS order by to resequence the rows
physically in the table.

Potrebbero piacerti anche