dbi services Blog
Welcome to the dbi services Blog! This blog focuses on database infrastructure and middleware topics. It covers technologies such as Oracle, Microsoft SQL Server, MySQL, Sybase, Linux, or Documentum (etc.). The dbi services blog represents the view of our consultants, not necessarily that of dbi services. Feel free to comment on the postings!
Index compression comes from Oracle 8i and has quite the same mechanism as table compression. Index compression eliminates duplicate column values in the leaf blocks. Let's see how it works:
We start by creating an index on an uncompressed table:
SQL> create index nocomp_i1 on nocomp (object_name,object_id);
Index created.
Let's have a look at how many leaf blocks the newly created index has:
SQL> select leaf_blocks from user_indexes where index_name = 'NOCOMP_I1';
LEAF_BLOCKS
407
If you want to estimate the ideal compression factor and the percentage of leaf blocks that can be saved, you need to consult INDEX_STATS view after validating the newly created index (watch out, this will lock the index):
SQL> validate index nocomp_i1;
Index analyzed.
SQL> select opt_cmpr_count,opt_cmpr_pctsave from index_stats;
OPT_CMPR_COUNT OPT_CMPR_PCTSAVE
-------------- ----------------
1 15
"opt_cmpr_count" = number of columns to compress in the index to get maximum space savings in the leaf blocks.
"opt_cmpr_pctsave" = percentage reduction in leaf block space used if we apply this compression count.
The previous result shows that the ideal compression factor is 1 and will reduce the number of leaf blocks by 15 %.
SQL> alter index nocomp_i1 rebuild compress 1;
Index altered.
SQL> select leaf_blocks from user_indexes where index_name = 'NOCOMP_I1';
LEAF_BLOCKS
345
The result is correct : 407 * 15 % = 61 and 407-61 = 346!
If we now validate the index again, we can verify that the compression factor of 1 is fine and no leaf blocks can be eliminated anymore:
SQL> validate index nocomp_i1; Index analyzed.
SQL> select opt_cmpr_count,opt_cmpr_pctsave from index_stats;
OPT_CMPR_COUNT OPT_CMPR_PCTSAVE
-------------- ----------------
1 0
Related Post
- How to handle mutex issues after migrating to Oracle 11.1 You have recently migrated to Oracle Database 11g Release 1 (11.1) and have had some issues with so called "mutexes"? Don't worry, these nasty sound...
- Oracle Basics (1): Oracle Database vs Oracle Instance While beginning to work with Oracle, one of the most common confusions is between Oracle Database and Oracle Instance. The term Oracle Database is m...
- Monitoring 11g databases with Grid Control 10.2.0.5 The Metalink note 949858.1 describes problems with 10.2.0.5 agents monitoring 11g databases - this might be the case if you have an "old" 10.2.0.5 Gri...
- Password Oracle : vos mots de passe sont-ils sécurisés ? Quelles sont les faiblesses de l'encryption des mots de passe Oracle ? Comment est-ce qu'Oracle crée les clés de hachage afin d'en améliorer la sécuri...
- Oracle Basics (2) - Data Storage What is finally the primary objective of a database? Storing Data The question is, how Oracle makes it. For many beginners, a confusing topic is to ...


