oracle 12c直方图收集的增强

在oracle 12c之前,收集直方图信息是相对比较耗费资源的,因为要重复扫描几次;在oracle 12c中,则有较大的提升,具体可参考https://jonathanlewis.wordpress.com/2013/07/14/12c-histograms/。

There are a few enhancements in 12c that might make a big difference to performance for a small investment in effort. One of the important enhancements comes from changes in histograms – which improve speed of collection with accuracy of results. The changes are so significant that I chose the topic as my presentation at OpenWorld last year.

In 11g Oracle gave us the option for using an “approximate NDV (number of distinct values)” for rapid and accurate collection of basic column stats. In 12c Oracle extends the mechanism to frequency histograms and a new type of frequency histogram called a “Top-N” histogram (also called a “Top-Frequency”histogram). At the same time the maximum number of buckets allowed for a histogram has gone up from 254 to 2000 2048 [corrected: see note 4 below] – although the default stays at 254 and you probably don’t need to increase it in most cases (remember the side effect you might have on the sysauxtablespace as Oracle automatically retains the historical stats).

Height-balanced histograms are still relatively expensive to collect – but there is a newer type of height-balanced histogram named the “Hybrid” histogram which gives you better information than the old height-balanced for the same amount of work and, thanks to the Top-N histogram you may find that some of your old (expensive, inaccurate) height-balanced histograms are replaced by cheap, accurate Top-N histograms.

In part 2 of this mini-series I’ll describe the new mechanism for the frequency histogram and the logic of the Top-N histogram and in part 3 I’ll describe the mechanism and demonstrate the benefits of the Hybrid histogram. The takeaway from this note, though, is that you need to look at your current stats collection and think about how a small change in strategy could both reduce the workload and improve the accuracy of your histograms.

原文地址:https://www.cnblogs.com/zhjh256/p/9867017.html