DBMS_STATS calculated wrong distinct keys with patch 7434973
[7434973] [bad] [Bug] [calculated] [dbms stats] [distinct] [perf] [sql distinct]
Symptom
*****************************************************************
* This note is released as a hot news. Check this note regularly
* for updates. Otherwise you will not be informed about major
* changes regarding the prerequisites, consequences and solutions.
* There will be no new hot news in case of an update of this note.
*****************************************************************
For tables with a rowcount approx. > 800.000, the value for DISTINCT_KEYS of columns used in nonunique indexes will be calculated with 0 if the statistics would be gathered by estimate percent < 100 percent.
As a result the CBO calculates a completly wrong index selectivity which end in a wrong execution plan.
Customers running in this issue notice a worse overall perfomance, as mostly the largest tables are affected.
To detect indexes that need the statistics to be recalculated you can use the following statement:
SELECT owner, table_name, index_name
FROM dba_indexes
WHERE owner = <owner>
AND distinct_keys = 0
AND num_rows > 800000;
Other terms
Bug 7434973, bad performance, DBMS_STATS, Full Table Scan, FTS
Reason and Prerequisites
The cause for this behavior is patch 7434973.
We have released this patch in May 2009 a few days later we notice this bahavior and removed patch from the SAP Marketplace. Customers who have still applied this patch should be de-install (rollback) patch 7434973 immediately
After de-installing patch 7434973 it is necessary to gather new statistcs for tables with a rowcount approx. > 800.000 to get a correct value of DISTINCT_KEYS for the indexes.
Solution
De-install (rollback) patch 7434973 and gather new statistics.
For the original problem patch 7434973 was released a new patch will provided after both issues are fixed.
Currently bug 8556340 is opened for this issue.