Tuesday, August 29, 2006

How are Indexes Being Used?

In keeping with my promise to periodically post blog entries based on questions I have received, here we have another question I have been asked:

If I have five indexes on a table, what is the best way to determine if all, some or none of the indexes are being used?

Here is the answer I sent:

The best approach would be to make sure you have run EXPLAIN on all of your production plans and packages. Then examine the PLAN_TABLE output for those indexes. For example:

SELECT *
FROM my.PLAN_TABLE
WHERE ACCESSNAME IN (put your list of indexes here);

Of course, this will not show the dynamic SQL that uses any of these indexes. There are tools on the market that can help you to gather SQL usage statistics and access path information for both static and dynamic SQL statements.

You might consider acquiring one of these tools if you use a lot of dynamic SQL. One such offering is NEON Enterprise Software’s SQL Performance Expert solution.

1 comment:

  1. Anonymous7:08 AM

    Hi Craig,

    I am a budding DBA. I have a question for you.

    What if the physical column order of the table and the primary key ( Unique Index ) column oder are differnt. Does this have any impact on the performance?

    It would be great if you can suggest me any IBM material abt the above question.

    Thanks in advance.
    mail2srig@yahoo.com

    ReplyDelete