Description: Oracle introduced a compression option for indexes in Oracle 8.1. You can create an index as compressed, or rebuild it to compress it.
Index compression is implemented at the index block level. Oracle stores each distinct combination of compressed column values found within a specific index leaf block in a "Prefix" table within the leaf block and assigns each combination a unique prefix number.
The benefits of compression come from the fact that a properly compressed index uses a smaller number of leaf blocks - which tends to mean that less I/O is involved when the index is used, there is a reduced amount of buffer cache flushing, and the optimizer is likely to calculate a lower cost for using that index for range scans.
Language: PL/SQL Highlight Mode: PLSQL Last Modified: March 06th, 2009
CREATEINDEX<index_name>ON(<first_column>,<second_column>)PCTFREE<integer>
TABLESPACE <tablespace_name>COMPRESS<integer *>;* Must be ATLEAST1 less than the NUMBEROF indexed columns
CREATEINDEX ix_pcodes
ON postal_code (state_abbrev, city_name, zip_code)PCTFREE0
TABLESPACE uwdata;
ANALYZE INDEX ix_pcodes VALIDATE STRUCTURE;
exec DBMS_STATS.gather_index_stats(USER,'IX_PCODES');SELECT opt_cmpr_count, opt_cmpr_pctsave
FROM index_stats;SELECTSUM(bytes)FROM user_segments
WHERE segment_name ='IX_PCODES';DROPINDEX ix_pcodes;CREATEINDEX ix_pcodes
ON postal_code (state_abbrev, city_name, zip_code)PCTFREE0
TABLESPACE uwdata
COMPRESS1;
ANALYZE INDEX ix_pcodes VALIDATE STRUCTURE;
exec DBMS_STATS.gather_index_stats(USER,'IX_PCODES');SELECT opt_cmpr_count, opt_cmpr_pctsave
FROM index_stats;SELECTSUM(bytes)FROM user_segments
WHERE segment_name ='IX_PCODES';DROPINDEX ix_pcodes;CREATEINDEX ix_pcodes
ON postal_code (state_abbrev, city_name, zip_code)PCTFREE0
TABLESPACE uwdata
COMPRESS2;
ANALYZE INDEX ix_pcodes VALIDATE STRUCTURE;
exec DBMS_STATS.gather_index_stats(USER,'IX_PCODES');SELECT opt_cmpr_count, opt_cmpr_pctsave
FROM index_stats;SELECTSUM(bytes)FROM user_segments
WHERE segment_name ='IX_PCODES';-- so pay attention to opt_comp_count
SQL University.net courses meet the most demanding needs of the business world for advanced education
in a cost-effective manner. SQL University.net courses are available immediately for IT professionals
and can be taken without disruption of your workplace schedule or processes.
Compared to traditional travel-based training, SQL University.net saves time and valuable corporate
resources, allowing companies to do more with less. That's our mission, and that's what we deliver.