{"id":139,"date":"2017-08-14T01:42:52","date_gmt":"2017-08-14T01:42:52","guid":{"rendered":"http:\/\/www.mrmarkyoung.com\/oracle\/?p=139"},"modified":"2017-08-14T01:42:52","modified_gmt":"2017-08-14T01:42:52","slug":"active-session-history-longest-sql","status":"publish","type":"post","link":"http:\/\/www.mrmarkyoung.com\/oracle\/2017\/08\/14\/active-session-history-longest-sql\/","title":{"rendered":"Active Session History Longest SQL"},"content":{"rendered":"\n<pre class=\"lang:default decode:true \" > SELECT\r\n        STAT.INSTANCE_NUMBER,\r\n        STAT.SQL_ID,\r\n         SQL_TEXT,\r\n         PLAN_HASH_VALUE,\r\n         PARSING_SCHEMA_NAME,\r\n         ELAPSED_TIME_DELTA\/1000000 SECONDS,\r\n         round((ELAPSED_TIME_DELTA\/1000000)\/60,2) MINUTES,\r\n         (ELAPSED_TIME_DELTA\/1000000) \/ EXECUTIONS_DELTA,\r\n         round((ELAPSED_TIME_DELTA\/1000000)\/60 \/ EXECUTIONS_DELTA,2) \"TIME PER EXEC\",\r\n         STAT.SNAP_ID,\r\n         SS.END_INTERVAL_TIME,\r\n         EXECUTIONS_DELTA\r\n    FROM DBA_HIST_SQLSTAT STAT, DBA_HIST_SQLTEXT TXT, DBA_HIST_SNAPSHOT SS\r\n   WHERE     STAT.SQL_ID = TXT.SQL_ID\r\n         AND STAT.DBID = TXT.DBID\r\n         AND SS.DBID = STAT.DBID\r\n         AND SS.INSTANCE_NUMBER = STAT.INSTANCE_NUMBER\r\n         AND STAT.SNAP_ID = SS.SNAP_ID\r\n         AND PARSING_SCHEMA_NAME = 'SCOTT'\r\n         AND SS.BEGIN_INTERVAL_TIME &gt;= SYSDATE - 5\r\n         AND ELAPSED_TIME_DELTA &gt;= round((8\/1000000))\r\n         AND PLAN_HASH_VALUE &lt;&gt; 0\r\n         AND EXECUTIONS_DELTA &gt; 1\r\nORDER BY 6 desc;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SELECT STAT.INSTANCE_NUMBER, STAT.SQL_ID, SQL_TEXT, PLAN_HASH_VALUE, PARSING_SCHEMA_NAME, ELAPSED_TIME_DELTA\/1000000 SECONDS, round((ELAPSED_TIME_DELTA\/1000000)\/60,2) MINUTES, (ELAPSED_TIME_DELTA\/1000000) \/ EXECUTIONS_DELTA, round((ELAPSED_TIME_DELTA\/1000000)\/60 \/ EXECUTIONS_DELTA,2) &#8220;TIME PER EXEC&#8221;, STAT.SNAP_ID, SS.END_INTERVAL_TIME, EXECUTIONS_DELTA FROM DBA_HIST_SQLSTAT STAT, DBA_HIST_SQLTEXT TXT, DBA_HIST_SNAPSHOT SS WHERE STAT.SQL_ID = TXT.SQL_ID AND STAT.DBID = TXT.DBID AND SS.DBID = STAT.DBID AND SS.INSTANCE_NUMBER = STAT.INSTANCE_NUMBER AND STAT.SNAP_ID = SS.SNAP_ID AND PARSING_SCHEMA_NAME = &#8216;SCOTT&#8217; AND SS.BEGIN_INTERVAL_TIME &#8230; <a title=\"Active Session History Longest SQL\" class=\"read-more\" href=\"http:\/\/www.mrmarkyoung.com\/oracle\/2017\/08\/14\/active-session-history-longest-sql\/\" aria-label=\"Read more about Active Session History Longest SQL\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[21],"class_list":["post-139","post","type-post","status-publish","format-standard","hentry","category-oracle-database","tag-active-sessions"],"_links":{"self":[{"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/posts\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/comments?post=139"}],"version-history":[{"count":1,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/posts\/139\/revisions"}],"predecessor-version":[{"id":140,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/posts\/139\/revisions\/140"}],"wp:attachment":[{"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/categories?post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/tags?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}