Oracle High Performance Tuning for 9i and 10g

 < Day Day Up > 


When considering indexes never be afraid of not indexing. On the contrary, do not always assume that an existing index should exist, simply because it does exist.

When considering use of unusual indexes such as clusters, bitmaps, and hashing be aware of their applications. The only index type amenable to data changes is a BTree index. All other index types are effectively read-only type indexes and are preferably never used otherwise. This is not always the case in some other relational databases but it is more often than not the case for Oracle Database. In most relational databases clusters, bitmaps, and hash indexes do not manage overflow well, if at all. Overflow in an index results in a bounce from the index block to an area outside of the original index structure, often negating the point of using the index in the first place.

Database administrators should always keep a watchful eye on indexing in a database. There is never really available time but when an application is released it is always best to reexamine all indexing. Quite often developers will create many indexes, sometimes each creating their own sets of indexes. The result can be overindexing. Too many indexes on a table will create a performance problem.

Tip 

Executing a DML command on a table will execute the same command on all of its indexes. For instance inserting a single row into a table with four indexes comprises five changes to the database.

Be especially vigilant for the use of bitmap and function-based indexes. Bitmap indexes are generally only effective in read-only situations. Function-based indexes are nice but I have never seen the Optimizer use one effectively in a commercial environment. However, this is often because configuration parameters are inappropriately set. The parameters QUERY_REWRITE_ENABLED and QUERY_REWRITE_INTEGRITY must be set to TRUE and TRUSTED respectively to allow use of function-based indexes. Developers and database administrators tend to like function-based indexes and bitmaps, especially when they have just read about them in the manual. Be alert for these unusual indexes because both bitmap and function-based indexes are largely ineffective and can be exceedingly detrimental to performance. One particular case I remember where many bitmap indexes were used. The database was in excess of 200 Gb and had a fairly large combination online and reporting production database. When one of the bitmaps was changed to a BTree index, a process taking 8 h to run completed in less than 3 min. This case involved heavy DML activity on the table on which the bitmap index was created.

7.1.1 When Not to Use Indexes

There are some circumstances where indexes can be detrimental to performance and sometimes those indexes should not exist. The Optimizer will occasionally ignore indexes and consider reading the entire table a faster option.

7.1.2 Utilizing Referential Integrity Indexes

Referential Integrity uses primary and foreign keys to validate relationships between rows in related tables. Oracle Database does not automatically create indexes on foreign keys and it is advisable to do so manually.

Data models of different forms can have either single-column unique integer identifiers at one extreme or large composite-column indexes at the other extreme. It is quite often possible that application SQL code can make good use of Referential Integrity indexes. This is generally the case when the data model matches the functionality of the application well. This is especially true in two cases.

Any kind of reporting or data warehousing application requirements will cause requirements for alternate indexing. Any online application with any type of reporting will generally be inclined in this direction as well.

If Referential Integrity indexing can be used for general SQL code tuning then do so as much as possible. Ultimately fewer indexes will be required and thus applications will perform better in general.

Alternate and Secondary Indexing

Alternate indexing is often referred to as secondary indexing. Alternate indexing includes any indexes created against tables in a data model which are not part of Referential Integrity constraints. Quite often the need for alternate indexing is a mismatch between the data model and functionality required by applications. Sometimes unique indexes are required on specific columns in data models other than unique integer identifier columns in every table. The application could deal with this particular issue but it may be best to place unique constraints in the database for the same reasons that Referential Integrity is not placed in the application or in triggers. Once again excessive alternate indexing could indicate data model problems or simply a mismatch between data model and application requirements.


 < Day Day Up > 

Категории