Advanced techniques with Oracle indexes
Although we have covered indexes extensively in the series, there are still some obscure index features that you can use to greatly promote the performance of your Oracle queries. While all indexes serve to avoid the costly full-table scan, Oracle has developed a wealth of new indexing options that can speed certain types of queries.
This module discusses the benefits of
- bitmapped indexes,
- STAR query operations,
- STAR transformation queries,
- a concatenated index, and
- a function-based index.
Index Database Object
An index is a database object used primarily to improve the performance of SQL queries. The function of a database index is similar to an index in the back of a book. A book index associates a topic with a page number. When you are locating information in a book, it is usually much faster to inspect the index first, find the topic of interest, and identify associated page numbers. With this information, you can navigate directly to specific page numbers in the book. In this situation, the number of pages you need to inspect is minimal. If there were no index, you would have to inspect every page of the book to find information. This results in a great deal of page turning, especially with large books. This is similar to an Oracle query that does not use an index and therefore has to scan every used block within a table. For large tables, this results in a great deal of I/O.
The book index's usefulness is directly correlated with the rarity of occurrence of a topic within the book.
For example, take this book; it would do no good to create an index on the topic of "performance" because every page in this book deals with performance. However, creating an index on the topic of "bitmap indexes" would be effective because there are only a few pages within the book that are applicable to this feature. Keep in mind that the index is not free. It consumes space in the back of the book, and if the material in the book is ever updated (like a second edition), every modification (insert, update, delete) potentially requires a corresponding change to the index. It is important to keep in mind that indexes consume space and require resources when updates occur.
Also, the person who creates the index for the book must consider which topics will be frequently looked up.
Topics that are selective and frequently accessed should be included in the book index. If an index in the back of the book is never looked up by a reader, then it unnecessarily wastes space.
Database Performance Techniques
Tuning with Indexes in Oracle
By the time you complete this module you should be able to:
- Explain the benefits of bitmapped indexes
- Describe a STAR query operation
- Describe a STAR transformation query
- Create a concatenated index
- Describe a function-based index
The next lesson reviews the limitations of standard Oracle indexes to understand why the new indexing methods were created.
Bitmap indexes are widely used in data warehousing applications, which have large amounts of data and ad hoc queries but a low level of concurrent transactions. For such applications, bitmap indexing provides:
- Reduced response time for large classes of ad hoc queries
- A substantial reduction of space usage compared to other indexing techniques
- Dramatic performance gains even on hardware with a relatively small number of CPUs or small amount of memory
- Very efficient maintenance during parallel DML and loads
Fully indexing a large table with a traditional B-tree index can be prohibitively expensive in terms of space because the indexes can be several times larger than the data in the table. Bitmap indexes are typically only a fraction of the size of the indexed data in the table.