This content has been marked as final. Show 92 replies
Unless there is a pile of information that allowed you to conclude that a slow process was the result of a corrupt index, I would strongly suspect that you don't have a corrupt index. Or if you do, that it is unrelated to your performance problem.
Let's start at the beginning-- why is the process slow?
- Do you have a trace of the session or a statspack report from a good run and from a slow run? What are the differences?
- What is the job doing?
- Did any query plans change?
- What is taking up most of the 6 hours the process is running?
Before doing this I would have always checked whether the explain plan it is taking is the best explain plain, and there are no waits for the session which has slowed down.
Then only I would have followed Oracle MetaLink note 122008.1 to rebuild the index
Run AWR and get the last AWR Report when it was good / bad.
Look at top 5 events, identify the sql's during good / bad times. If SQL's are executing at the same speed then problem lies somewhere else.
Such a drastic slowdown is probably external to the Database.
Was there any change environmental or otherwise. Any stats change ?
Interestingly, I mention Metalink Note 122008 a number of times in my Index Seminar as a perfect example of how not+ to determine when to rebuild an index.
Thankfully, Oracle have pulled the error filled note from Metalink and with a bit of luck, it will never resurface again to confuse folk.
Why do you diss the Oracle documentation, and then fail to show the OP a method that does work?
I mention Metalink Note 122008 a number of times in my Index Seminar as a perfect example of how not to determine when to rebuild an index.
That's not very helpful!
In many cases, evaluating an index for rebuilding is a waste of time.
It can take more reources to evaluate whether an index needs rebuilding than to actually rebuild it! Done properly, index rebuilding is 100% safe, and recommended by Oracle Corporation. . . .
Oracle's index rebuilding guidelines appear in Metalink note 77574.1 (dated April 2007) recommends that indexes be periodically examined to see if they are candidates for an index rebuild:
“When an index is skewed, parts of an index are accessed more frequently than others. As a result, disk contention may occur, creating a bottleneck in performance.
It is important to periodically examine your indexes to determine if they have become skewed and might need to be rebuilt.”
Interestingly, Oracle DBA Jim Spath has shown that regular rebuilding of high DML indexes should be scheduled on a regular basis:
Thankfully, Oracle have pulled the error filled note from Metalink
“This index should be reorganized on a regular basis. . .
What is happening here is the index is becoming unbalanced through constant inserts and deletes.
Over time, the space the index occupies will continue to grow though there may be zero rows at the time the system starts and stops.
Each deleted row continues to occupy space in the index segment until a rebuild is done.”
Suggesting that "Each deleted row continues to occupy space in the index segment until a rebuild is done” is of course not correct in most cases either as most deleted space is automatically reclaimed and reused by Oracle.
You can only lead a horse to water ... ;)
It depends on how you define "unbalanced"!
By design they can not become unbalanced. EVER!
When Oracle does a logical delete of a leaf node, the "logical" structire of the b-tree is out of balance.
You're absolutely right that we should define what we mean by "balanced". In my view, "balanced" means that the number of "hops" from the root block to any leaf block is always the same. In other words, it's not possible to do an index look up on "Burleson" and go root->branch-leaf containing "Bujrleson" but look up "Foote" and go root->branch->branch->leaf containing "Foote".
Based on that definition of "balanced", Sybrand is correct.
If you have an alternate definition of "balanced", please clarify it.
Yes, I was asked many years ago by Oracle Support to write a few words to try and clarify why most indexes don't actually need to be rebuilt as Oracle automatically manages things perfectly OK in most scenarios.
Probably a note that could go as well :)