Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

oracle search

Wednesday, August 6, 2008

423,551 Invalid Indexes ....oracle

A friend received an alarming email from a commendably proactive DBA who was concerned that he had discovered a potentially serious performance issue on the production system:

The following result shows there are many invalid indexes. For example, in the first row we see that there are nearly 423551 invalid indexes for just one row of a table. So if we rebuilt the index it would improve the performance.

Wow, that sure is a lot of invalid indexes for just one row of a table. For the sake of anonymity, I've run his query against the SCOTT/TIGER schema, where fortunately there are only 14 invalid indexes (or perhaps 10, if that's how you count them). Perhaps you can see what the problem might be:

SELECT DISTINCT
t.table_name
, i.index_name
, t.num_rows table_rows
, i.num_rows index_rows
FROM dba_tables t
, dba_indexes i
WHERE t.table_name = 'DEPT'
AND t.owner = 'SCOTT'
AND i.owner = t.owner
AND i.index_type = 'NORMAL';

TABLE_NAME INDEX_NAME TABLE_ROWS INDEX_ROWS
------------------------------ ------------------------------ ---------- ----------
DEPT PK_EMP 4 14
DEPT EMP_DEPT_IX 4 14
DEPT PK_DEPT 4 4
DEPT PK_SALGRADE 4 5

4 rows selected.

There is worse to come. It's not just DEPT that has invalid indexes. He goes on:

The following result shows there are many invalid indexes, so if we rebuild the index, it would improve the performance. At the same time from the first and last rows, indexes are not being used, so we need to look into it.
TABLE_NAME                     INDEX_NAME                     TABLE_ROWS INDEX_ROWS
------------------------------ ------------------------------ ---------- ----------
SALGRADE PK_DEPT 5 4
SALGRADE PK_EMP 5 14
SALGRADE EMP_DEPT_IX 5 14
SALGRADE PK_SALGRADE 5 5

TABLE_NAME INDEX_NAME TABLE_ROWS INDEX_ROWS
------------------------------ ------------------------------ ---------- ----------
EMP PK_DEPT 14 4
EMP PK_EMP 14 14
EMP EMP_DEPT_IX 14 14
EMP PK_SALGRADE 14 5

I just can't help wondering what he thinks an index is.

No comments: