How to use DBMS_STATS DIFF_TABLE_STATS functions

In 11g, Oracle introduced the DBMS_STAT.DIFF_TABLE_STATS functions to help you compare two sets of statistics for a table along with all its dependent objects (indexes, columns, partitions).

There are three versions of this function depending on where the statistics being compared are located:

  • DBMS_STAT.DIFF_TABLE_STATS_IN_HISTORY (compares statistics for a table from two timestamps in the past)
  • DBMS_STAT.DIFF_TABLE_STATS_IN_PENDING (compares pending statistics and statistics as of a timestamp or statistics from the data dictionary)
  • DBMS_STAT.DIFF_TABLE_STATS_IN_STATTAB (compares statistics from a user statistics table and the data dictionary, from two different user statistics tables, or a single user statistics table using two different STATSIDs)

The functions return a report that has three sections:

  1. Basic table statistics
    The report compares the basic table statistics (number of rows, blocks, etc.).
  2. Column statistics
    The second section of the report examines column statistics, including histograms.
  3. Index Statistics
    The final section of the report covers differences in index statistics.

Statistics will only be displayed in the report if the difference in the statistics exceeds a certain threshold (%). The threshold can be specified as an argument to the functions (PCTTHRESHOLD); the default value is 10%. The statistics corresponding to the first source, typically the current table stats in the data dictionary, will be used to compute the differential percentage.

The functions also return the MAXDIFFPCT (a number) along with the report. This is the maximum percentage difference between the statistics. These differences can come from the table, column, or index statistics.

Let’s look at an example.
Continue reading “How to use DBMS_STATS DIFF_TABLE_STATS functions”

Oracle Launches TimesTen Scaleout!

What a week for announcements! First we had Oracle Database 18c available on-premises and now Oracle TimesTen Scaleout.

If you are not familiar with TimesTen, let me reminder you that it’s Oracle’s  In-Memory Database. In fact, it’s been a leading in-memory database for mission critical applications for over 20 years, and today they just launched an exciting new scalability feature called TimesTen Scaleout.

So, What is Scaleout?

TimesTen Scaleout is a distributed database, with a shared nothing architecture specifically designed to address real-time, transaction processing workloads. Think IoT, real-time trading, telecommunications billing or real-time fraud detection.

Continue reading “Oracle Launches TimesTen Scaleout!”

SQL Plan Management – Selective Automatic Plan Capture Now Available!

Over the years, Oracle has provided a number of techniques to help you control the execution plan for a SQL statement, such as Store Outlines and SQL Profiles but for me, the only feature to truly give you plan stability is SQL Plan Management (SPM). It’s this true plan stability that has made me a big fan of SPM ever since it was introduced in Oracle Database 11g.

With SPM only known or accepted execution plans are used. That doesn’t mean Oracle won’t parse your SQL statements, it will. But before the execution plan generated at parse is used, we will confirm it is an accepted plan by comparing the PLAN_HASH_VALUE to that of the accepted plan. If they match, we go ahead and use that plan.

Continue reading “SQL Plan Management – Selective Automatic Plan Capture Now Available!”

Coming Soon!

I recently switched my role in the Oracle Database Development team from the product management team for Database In-Memory and Advance Compression to be a database evangelist.

With this new role comes a new blog and an opportunity for me to broaden the topics I blog about. I’ll also have an opportunity to share my own opinion and approach to optimizing your Oracle investment.

I hope you will join me on this new journey and will learn a little something along the way!

%d bloggers like this: