| My OracleGuide | Index Optimization Scripts | About Feedback | Products |
|
Information regarding index usage and performance statistics can be obtained from dynamic performance views. By looking at the queries it will be possible to find the queries that are doing full table scan and the ones that can benefit from new indexes.
The following data dictionary views are useful for the data analysis. The shared pool keeps the most recent SQL statements, plan and statistics in the cache.
To list SQL statements in Shared pool
Queries having full table scan of the employee table in scott schema
Get Expensive queries
Find the expensive plan hash value
For the above plan_hash_value, say p1, get addres and hash_value of one SQL
Using the above address and hash_value query the v$sql_plan to get the execution plan for the above query
Monitoring Index UsageThere are cases where the existing indexes are not used. This can increase the database writes for tables with heavy transactions. You can use the view v$object_usage to monitor index usage. The view displays statistics about index usage gathered from the database. Monitor for sufficient number of days. All indexes that have been used at least once can be displayed in this view.
Set index monitoring
To turn off monitoring
To generate monitoring scripts for all indexes
To turn off monitoring for all indexes
Find unused indexes
Choosing the index typeA bitmap index is more suitable where there are very few distinct values.The following query can be used to get a list of indexes where the leading column has very few distinct values. Before running this query the tables or schema has to be analyzed with "COMPUTE STATISTICS" and the option 'for all columns'
select * from(
select a.index_name,
Partitiond global indexesAs the number rows in the table increases the height of the index tree and also the index maintenance cost increases. Partitioning helps to reduce the size of the index tree. Even for a table that is partitioned, partitiond global indexes can be created for the indexes that are not based on the table partition key.Consider the sales table with millions of rows. A partitioned index has to be created based on customer_id. It is decided to have one million rows per index partition. The following query can be used to select range boundaries for index partition
select * from(
select customer_id, rownum r1 from
Create the partitioned index
|