That is a BIG question. Please bear with me as I give it a shot and feel free to excuse or correct any mistakes (I'm only human and computers are soooo complex now). This will take awhile, so feel free to skip the techno babble to get to the "good stuff". At the risk of ruining what little credibility I have:
<pedagogical techno babble on>
Oracle indexes are (or at least they used to be) "b-tree" structures. Their actual implementation is probably a lot more complex, but a basic b-tree includes nodes and pointers. Each node contains index values and corresponding pointers to "other nodes or data records". B-tree searches are recursive. The search algorithm starts at the root node and moves to other nodes depending on the "search value":
Search time is directly related to the number of nodes that need to be accessed for each search value. The best average search time happens when all nodes are completely full and the b-tree "depth" (i.e. the maximum number of nodes between the root node and the "last" node in each tree branch) is minimized. Unfortunately, inserting a new index value in a "completely full" tree takes longer (hence the "fill factor"). Also, index value changes (e.g. when table rows are modified) could take a very long time if the tree depth had to be minimized each time. Given all the variables, Oracle algorithms try to give the "best" performance balance for insertions, deletions, updates, and searches.
When a b-tree index is first created, the algorithms generate the "best" balanced tree. The tree becomes more "unbalanced" as data changes are made ... resulting in longer search times. Dropping and recreating Oracle indexes can result in very significant performance gains (orders of magnitude faster).
<pedagogical techno babble off>
"Invalid" indexes are a lot easier to explain. Sometimes Oracle "breaks" (stray radiation from Mars?) and indexes become corrupted. In addition to possible performance problems, I believe corrupt indexes could even cause invalid query results. Oracle has ways to detect corrupt indexes. If I were a DBA, I might even be able to tell you what they are, but I'm not. Sorry ...
As for "preventing this from occurring", that's why DBAs get paid the big bucks! <sarcasm> I don't think there is much you can do with corrupt indexes (other than fix them when you find them), but you can drop and re-create unbalanced indexes periodically. A few months ago, we reduced response time for one query from 60+ seconds to about 15 seconds by recreating one index. There are probably even some tools that improve index performance "on the fly". Some people do this as part of their regular maintenance, others prefer to wait till things get slow. Your choice ...
How's that for filling up my lunch break? Now, aren't you sorry you asked? <grin>
Steve
Tina_Burnett@NAS.ADP.COM wrote:
I have found that dropping and re-creating the index(es) resolves many--
performance problems.So what do you mean by Oracle indexes sometimes become "unbalanced" (or
even "invalid") and is there
a way to prevent this from occurring ?Tina Burnett
Application Programmer/Analyst
ADP CSS HRizon Custom Programming(770) 360-3199