{
  "date": "2015-09-29T19:52:43",
  "slug": "nothing-in-feature-usage-statistics-since-12c",
  "link": "https://www.dbi-services.com/blog/nothing-in-feature-usage-statistics-since-12c/",
  "title": {
    "rendered": "Nothing in feature usage statistics since 12c?"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.<br />\nIt don&#8217;t want to rub salt in the wound about 12c upgrades and Adaptive Dynamic Sampling being overzealous, but here is a case with an unexpected consequence: you see nothing in the &#8216;Database Feature Usage&#8217; since migration.<br />\n<!--more--><br />\nThe photo novel starts like this:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-1.png\" alt=\"orafu-1\" width=\"1316\" height=\"548\" class=\"alignnone size-full wp-image-4099\" /></a><br />\nwe are in September and when I check the &#8216;Database Feature Usage&#8217; page I see nothing gathered since February.</p>\n<p>It&#8217;s quite embarrassing as this is the only way to ensure that I&#8217;m not using features that are not available with the license options I have.</p>\n<p>Well, I have Tuning Pack so I can use SQL Monitoring, and this is what I remark coincidentally:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-3.png\" alt=\"orafu-3\" width=\"894\" height=\"264\" class=\"alignnone size-full wp-image-4101\" /></a></p>\n<p>You see &#8216;DBMS_FEATURE&#8217; functions ending in ORA-12751 error after 20 minutes of heavy CPU usage.</p>\n<p>ORA-12751 is &#8220;cpu time or run time policy violation&#8221;, it&#8217;s an internal limit for queries run by MMON, such as the one that collects the features usage.</p>\n<p>This can explain why the feature usage is not collected. Let&#8217;s check the history about it:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-2.png\" alt=\"orafu-2\" width=\"1088\" height=\"549\" class=\"alignnone size-full wp-image-4100\" /></a></p>\n<p>Thanks to AWR that stores SQL Monitoring statistics, we can see that the function always fail. So why is it so long to run?</p>\n<p>Here is a pattern that we start to see a lot when upgrading to 12c.</p>\n<p>If you have attended to my &#8216;AWR straight to the goal&#8217; session then you know the path I follow: time model, top events, statements, etc.<br />\n(If you didn&#8217;t, then come to Birmingham in December at <a href=\"http://www.tech15.ukoug.org/default.asp?p=12861&amp;dlgact=shwprs&amp;prs_prsid=10652&amp;day_dayid=94\">tech15</a> or in January at Oracle Midlands)</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-6.png\" alt=\"orafu-6\" width=\"592\" height=\"504\" class=\"alignnone size-full wp-image-4104\" /></a></p>\n<p>lot of parsing time here&#8230;</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-5.png\" alt=\"orafu-5\" width=\"760\" height=\"279\" class=\"alignnone size-full wp-image-4103\" /></a></p>\n<p>Lot of time in CPU and a small result cache contention&#8230;</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-7.png\" alt=\"orafu-7\" width=\"1107\" height=\"301\" class=\"alignnone size-full wp-image-4105\" /></a></p>\n<p>One SQL query that takes all the time of the dbms feature call. Note that /* DS_SVC */ is dynamic sampling&#8230;</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-8.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-8.png\" alt=\"orafu-8\" width=\"1185\" height=\"193\" class=\"alignnone size-full wp-image-4106\" /></a></p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-9.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-9.png\" alt=\"orafu-9\" width=\"831\" height=\"220\" class=\"alignnone size-full wp-image-4107\" /></a></p>\n<p>Let&#8217;s put it together: </p>\n<ul>\n<li>long hard parse</li>\n<li>result cache contention</li>\n<li>long dynamic sampling query</li>\n</ul>\n<p>This is Adaptive Dynamic Sampling. The feature usage function run a lot of queries on big tables (AWR history, RMAN history, etc) and the 12c ADS queries on those big tables are very long. Fortunately there is a timeout after 20 minutes. But the result is that we have no result: I cannot know which features are used.</p>\n<h3>So what?</h3>\n<p>The goal of this post is not to tune those internal queries. There is enough to do with production queries.<br />\nThe goal is to explain how it is possible to see nothing in DBA_FEATURE_USAGE_STATISTICS for past months.<br />\nNow, if you have an LMS auditor that find it suspicious, then you can prove that you did nothing bad&#8230; except upgrading to 12c 😉<br />\nWell, you should adapt the method presented here of course: don&#8217;t show an AWR report if you don&#8217;t have Diagnostic Pack!</p>\n<h3>Added 1st Oct. 2015</h3>\n<p>Of course, when you see a problem you check if the problem occurs elsewhere.<br />\nI was on a server with 50 12c instances and checked the CPU usage:<br />\n<a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-10.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/orafu-10.png\" alt=\"orafu-10\" width=\"1306\" height=\"331\" class=\"alignnone size-full wp-image-4156\" /></a><br />\nWhat happens around 14:30 is that a lot of instances are running that feature usage query. I&#8217;m not sure about that, but I think that the time when it run is determined by the instance startup time and on that server all instances have been started after a server maintenance.</p>\n<p>The query is: auyf8px9ywc6j</p>\n<pre><code>\nWITH SNAP_RANGES AS\n(SELECT /*+ FULL(ST) */ SN.DBID ,SN.INSTANCE_NUMBER ,SN.STARTUP_TIME ,ST.STAT_ID ,ST.STAT_NAME ,MIN(SN.SNAP_ID) AS MIN_SNAP ,MAX(SN.SNAP_ID) AS MAX_SNAP ,MIN(CAST(BEGIN_INTERVAL_TIME AS DATE)) AS MIN_DATE ,MAX(CAST(END_INTERVAL_TIME AS DATE)) AS MAX_DATE\nFROM DBA_HIST_SNAPSHOT SN ,WRH$_STAT_NAME ST\nWHERE SN.BEGIN_INTERVAL_TIME &gt; TRUNC(SYSDATE) - 7 AND SN.END_INTERVAL_TIME &lt; TRUNC(SYSDATE) AND SN.DBID = ST.DBID AND ST.STAT_NAME IN (&#039;DB time&#039;, &#039;DB CPU&#039;) GROUP BY SN.DBID,SN.INSTANCE_NUMBER,SN.STARTUP_TIME,ST.STAT_ID,ST.STAT_NAME ) ,DELTA_DATA AS\n(SELECT SR.DBID ,SR.INSTANCE_NUMBER ,SR.STAT_NAME ,CASE WHEN SR.STARTUP_TIME BETWEEN SR.MIN_DATE AND SR.MAX_DATE THEN TM1.VALUE + (TM2.VALUE - TM1.VALUE) ELSE (TM2.VALUE - TM1.VALUE) END AS DELTA_TIME\nFROM WRH$_SYS_TIME_MODEL TM1 ,WRH$_SYS_TIME_MODEL TM2 ,SNAP_RANGES SR\nWHERE TM1.DBID = SR.DBID AND TM1.INSTANCE_NUMBER = SR.INSTANCE_NUMBER AND TM1.SNAP_ID = SR.MIN_SNAP AND TM1.STAT_ID = SR.STAT_ID AND TM2.DBID = SR.DBID AND TM2.INSTANCE_NUMBER = SR.INSTANCE_NUMBER AND TM2.SNAP_ID = SR.MAX_SNAP AND TM2.STAT_ID = SR.STAT_ID )\nSELECT STAT_NAME ,ROUND(SUM(DELTA_TIME/1000000),2) AS SECS\nFROM DELTA_DATA GROUP BY STAT_NAME\n</code></pre>\n<p>It&#8217;s a query that gathers the following:</p>\n<pre><code>\nSTAT_NAME        SECS\n---------- ----------\nDB CPU       76451.04\nDB time     147707.98\n</code></pre>\n<p>but the problem is the Adaptive Dynamic Sampling that is behind.</p>\n<p>I&#8217;ve no solution yet, but Not-a-Bug number 14510010&#8243; suggests that the query is not run when _swrf_mmon_dbfus&#8221;=false but of course your usage of Diagnostic Pack will not be monitored.</p>\n<h3>Update June 6th, 2016</h3>\n<p>The best solution to the issue (following the Rule #1 of troubleshooting: the scope of the solution should match the scope of the problem) is on Ludovico Caldara blog post: <a href=\"http://www.ludovicocaldara.net/dba/cpu-usage-12c-dbms_feature_awr/\">http://www.ludovicocaldara.net/dba/cpu-usage-12c-dbms_feature_awr/</a></p>\n",
    "protected": false
  }
}
