After writing about table statistics, I tried my query to retrieve them many times. Soon I found out, I couldn’t find index statistics data. After a while I figured it out. Duh! The table is called WRI$_OPTSTAT_TAB_HISTORY. So I quickly went looking for other WRI$_OPTSTAT_ tables and found them:
WRI$_OPTSTAT_IND_HISTORY – contains index statistics history, including the row count, blevels, leaf count, distinct keys and clustering factor. And not to mention the sample size.
WRI$_OPTSTAT_HISTHEAD_HISTORY – contains column statistics, like the null count, the density, low values and high values, the number of distinct values in the sample and so on. Here also the sample size, which I have seen varying in some cases of performance issues with column statistics.
WRI$_OPTSTAT_HISTGRM_HISTORY – contains a history of histogram data. You’ll find colums like bucket, endpoint, epvalue. I haven’t tried this one out, for fear of getting overwelmed with data. But if ever you suspect wild changes in the number of buckets, you might want to look the data up here.
WRI$_OPTSTAT_AUX_HISTORY – If you regularely gather system statistics, I’ll assume you will find older versions of those statistics here.
There are more WRI$_OPTSTAT_ tables, for which I haven’t found a use yet:
These statistics history tables are very valuable to see what has changed in data and amount of data. When query performance suddenly goes wrong without a clear explanation, you might find it here. Enjoy!