目录
前言
众所周知,从本月初到现在我已经连续在墨天轮上连续发表了三篇原创博客文章,它们按发表的时间顺序(也是遵循由易到难的层层递进方式)是:
经过最近几天的一番研究,我发现这个图表的相关SQL查询只能查看“最近1小时”和“最近1分钟”的数据。从Oracle的官方文档19c中找到的查看最近24小时、最近7天、最近31天和自定义时间段的视图是DBA_HIST_WAITCLASSMET_HISTORY。现将它的介绍描述如下:
DBA_HIST_WAITCLASSMET_HISTORY displays the history of the wait event class metric data kept by the Workload Repository.
从上面简要的介绍来看,DBA_HIST_WAITCLASSMET_HISTORY的数据应该是保留到了AWR中。但是我在11gR2,19c和21c中却发现这个视图的查询数据均为零。详见我的SQL查询和结果:
SQL*Plus: Release 11.2.0.4.0 Production on Mon Nov 29 10:39:13 2021
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
10:39:57 SQL> SELECT COUNT(*) FROM dba_hist_waitclassmet_history;
COUNT(*)
----------
0
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Nov 29 10:40:52 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
10:40:52 SQL> SELECT COUNT(*) FROM dba_hist_waitclassmet_history;
COUNT(*)
----------
0
SQL*Plus: Release 21.0.0.0.0 - Production on Mon Nov 29 10:41:12 2021
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
10:41:12 SQL> SELECT COUNT(*) FROM dba_hist_waitclassmet_history;
COUNT(*)
----------
0
于是,我在FreeLists的Oracle空间发了一个帖子,静等专家朋友们的答复吧。所以目前仅能从两个维度(最近1小时和最近1分钟)来详细阐述相关的可视化操作了。由于这个图表只是基本的“面积堆叠图”,因此我们仍然使用Oracle SQL Developer 21.2中的用户自定义报告进行可视化即可。
维度目录列表
最近1小时的每个活动类的活动会话
用ASH查看活动会话
-- Active Sessions (in ASH) Per Activity Class from EMCC 13.5 in Last 1 Hour.
SET LINESIZE 200
SET PAGESIZE 200
COLUMN sample_time FORMAT a19
COLUMN activity_class FORMAT a15
ALTER SESSION SET nls_date_format = 'yyyy-mm-dd hh24:mi:ss';
SELECT TRUNC(CAST(sample_time AS DATE), 'mi') sample_time
, DECODE(wait_class, 'User I/O', 'User I/O', NULL, 'CPU', 'Wait') activity_class
, ROUND(COUNT(*)/6e1, 4) active_sessions
FROM v$active_session_history
WHERE (wait_class <> 'Idle' OR wait_class IS NULL)
AND CAST(sample_time AS DATE) >= SYSDATE - 1/24
GROUP BY TRUNC(CAST(sample_time AS DATE), 'mi')
, DECODE(wait_class, 'User I/O', 'User I/O', NULL, 'CPU', 'Wait')
ORDER BY activity_class
, sample_time
;
SAMPLE_TIME ACTIVITY_CLASS ACTIVE_SESSIONS
------------------- --------------- ---------------
......
2021-11-29 14:07:00 CPU .3833 <<==
......
2021-11-29 14:06:00 User I/O .0167 ?
......
2021-11-29 14:07:00 Wait 1.6333 <<==
......
123 rows selected.
接着我们去查看同一时间(“2021-11-29 14:07”)EMCC 13.5图表中显示的数据(以便和上述ASH中的数据进行对比),如下三图(依次为:CPU、User I/O和Wait)所示:
经过反复的对比,始终发现两者之间存在一定的差异,这也间接说明一个问题,我们的SQL查询不匹配EMCC的图表数据,也有可能EMCC图表的数据来源不是我们前面的那个SQL查询。
通过AskTOM寻求帮助
于是,我到AskTOM上寻求Connor McDonald的帮助,请看这里或下面的两张屏幕截图:
从第二个图中我们可以看到,Connor建议去查询列usecs_per_row(从12.2版本开始提供)。于是,我稍微调整了前面的SQL代码并在我的测试库19.3中进行相应的查询,结果同样让我大跌眼镜,仍旧存在差异。索性又给Connor做了回复,如下图所示:
后来,他这样说道,已和EM团队进行沟通,可能不只是SQL,或许有其他因素决定,数据不可能100%一致。
到此为止,我卡住了!!!难道止步不前吗?
感谢Kyle Hailey
此时,我突然想到了Kyle Hailey的Oracle CPU Time这篇文章,尤其在最后的更新段落中,他的部分SQL代码给了我一些非常有价值的线索,因此只截取这部分代码,如下所示:
......
select
decode(n.wait_class,'User I/O','User I/O',
'Commit','Commit',
'Wait') CLASS,
sum(round(m.time_waited/m.INTSIZE_CSEC,3)) AAS,
BEGIN_TIME ,
END_TIME
from v$waitclassmetric m,
v$system_wait_class n
where m.wait_class_id=n.wait_class_id
and n.wait_class != 'Idle'
group by decode(n.wait_class,'User I/O','User I/O', 'Commit','Commit', 'Wait'), BEGIN_TIME, END_TIME
union
select 'CPU_ORA_CONSUMED' CLASS,
round(value/100,3) AAS,
BEGIN_TIME ,
END_TIME
from v$sysmetric
where metric_name='CPU Usage Per Sec'
and group_id=2
......
从上面的代码中我们可以看到,Kyle Hailey使用视图v$waitclassmetric、v$system_wait_class和v$sysmetric来查询CPU、User I/O和Wait。这里引用一下官档19c中对这些视图的简要描述:
V$WAITCLASSMETRIC displays metric values of wait classes for the most recent 60-second interval. A history of the last one hour will be kept in the system.
V$SYSTEM_WAIT_CLASS displays the instance-wide time totals for each registered wait class.
V$SYSMETRIC displays the system metric values captured for the most current time interval for both the long duration (60-second) and short duration (15-second) system metrics.
通过前面的描述,我们已经知道这几个视图可以查询最近60秒(也就是1分钟)的度量数据。而我们这里要查询的是最近1小时的数据,非常巧合的是,官档中呈现的是一个视图列表,在视图V$WAITCLASSMETRIC后面紧接着的是另一个相关的视图V$WAITCLASSMETRIC_HISTORY,它可以查询最近1小时的度量数据,官档的描述是这样的:
V$WAITCLASSMETRIC_HISTORY displays metric values of wait classes for all intervals in the last one hour.
The columns for V$WAITCLASSMETRIC_HISTORY are the same as those for V$WAITCLASSMETRIC.
视图V$SYSMETRIC_HISTORY同样如此,它也可以查询最近1小时的度量数据,在此也引用一下官档的描述:
V$SYSMETRIC_HISTORY displays all system metric values available in the database. Both long duration (60-second with 1 hour history) and short duration (15-second with one-interval only) metrics are displayed by this view.
探索CPU
说到这里,让我们先查询一下度量名称“CPU Usage Per Sec”的度量单位,详见如下SQL代码和查询结果:
SET LINESIZE 200
COLUMN metric_name FORMAT a30
COLUMN metric_unit FORMAT a25
SELECT DISTINCT metric_name
, metric_unit
FROM v$sysmetric_history
WHERE metric_name LIKE '%CPU%'
ORDER BY 1
;
METRIC_NAME METRIC_UNIT
------------------------------ -------------------------
Background CPU Usage Per Sec CentiSeconds Per Second
CPU Usage Per Sec CentiSeconds Per Second
CPU Usage Per Txn CentiSeconds Per Txn
Database CPU Time Ratio % Cpu/DB_Time
Host CPU Usage Per Sec CentiSeconds Per Second
Host CPU Utilization (%) % Busy/(Idle+Busy)
6 rows selected.
我们注意到,它的度量单位是“厘秒每秒”,所以我们在相应的SQL查询中应该将“CPU Usage Per Sec”的值除以100折/换算成“秒每秒”。接着我们用视图V$SYSMETRIC_HISTORY去查询按CPU分类的活动会话数据,SQL代码和查询结果如下所示(仍以“2021-11-29 14:07”为例,这样有利于和EMCC的图表数据进行对比):
-- 'CPU Usage Per Sec' is right to the legend 'CPU' from the "Active Sessions Per Activity Class" Graph of EMCC 13.5.
SET LINESIZE 200
SET PAGESIZE 100
COLUMN sample_time FORMAT a11
COLUMN metric_name FORMAT a11
COLUMN active_sessions FORMAT 999,999.9999
SELECT TO_CHAR(end_time, 'hh24:mi:ss') sample_time
, DECODE(metric_name, 'CPU Usage Per Sec', 'CPU') metric_name
, ROUND(value/1e2, 4) active_sessions
FROM v$sysmetric_history
WHERE metric_name = 'CPU Usage Per Sec'
AND group_id = 2
AND end_time >= SYSDATE - INTERVAL '60' MINUTE
ORDER BY sample_time
;
SAMPLE_TIME METRIC_NAME ACTIVE_SESSIONS
----------- ----------- ---------------
......
14:07:29 CPU .8005
......
60 rows selected.
非常棒,这次终于(和前面呈现的EMCC中CPU为0.8005的取值相同)一致了,这正是我翘首以盼的结果,虽然它来得迟了一些,索性再贴一下吧,哈哈!!!
探索User I/O
马不停蹄,我们接着用视图V$WAITCLASSMETRIC_HISTORY和V$SYSTEM_WAIT_CLASS进行关联去查按User I/O分类的活动会话数据,具体的SQL查询和查询结果(只显示“2021-11-29 14:07”这一行)是:
-- 'User I/O' is right as well to the legend 'User I/O' from the "Active Sessions Per Activity Class" Graph of EMCC 13.5.
SET LINESIZE 200
SET PAGESIZE 100
COLUMN sample_time FORMAT a11
COLUMN metric_name FORMAT a11
COLUMN active_sessions FORMAT 999,999.9999
SELECT TO_CHAR(wcmh.end_time, 'hh24:mi:ss') sample_time
, swc.wait_class metric_name
, ROUND(wcmh.time_waited/wcmh.intsize_csec, 4) active_sessions
FROM v$waitclassmetric_history wcmh
, v$system_wait_class swc
WHERE wcmh.wait_class_id = swc.wait_class_id
AND swc.wait_class = 'User I/O'
AND wcmh.end_time >= SYSDATE - INTERVAL '60' MINUTE
ORDER BY sample_time
;
SAMPLE_TIME METRIC_NAME ACTIVE_SESSIONS
----------- ----------- ---------------
......
14:07:29 User I/O .0064
......
60 rows selected.
这个结果也和先前的EMCC图表的显示数据惊人的一致,不信你看!
探索Wait
戒骄戒躁,我们来想一想这个Wait分类如何查询呢?与此同时,我在视图V$SYSMETRIC_HISTORY的列metric_name中发现了两个有用的度量名称“Database Time Per Sec”和“Database Wait Time Ratio”,相关的查询为:
SET LINESIZE 200
COLUMN metric_name FORMAT a30
COLUMN metric_unit FORMAT a25
SELECT DISTINCT metric_name
, metric_unit
FROM v$sysmetric_history
WHERE metric_name LIKE '%Database%'
ORDER BY 1
;
METRIC_NAME METRIC_UNIT
------------------------------ -------------------------
Database CPU Time Ratio % Cpu/DB_Time
Database Time Per Sec CentiSeconds Per Second
Database Wait Time Ratio % Wait/DB_Time
将二者相乘,岂不是我们想要的Wait查询?话不多说,详见如下代码和查询结果(只显示“2021-11-29 14:07”这一行):
-- But 'Wait' is still not fully identical to EMCC 13.5 when using 'Database Time Per Sec' * 'Database Wait Time Ratio'.
SET LINESIZE 200
SET PAGESIZE 100
COLUMN sample_time FORMAT a11
COLUMN metric_name FORMAT a11
COLUMN active_sessions FORMAT 999,999.9999
WITH
wait AS
(
SELECT TO_CHAR(end_time, 'hh24:mi:ss') sample_time
, MAX(DECODE(metric_name, 'Database Time Per Sec' , value/1e2)) aas_value
, MAX(DECODE(metric_name, 'Database Wait Time Ratio', value/1e2)) wait_ratio
FROM v$sysmetric_history
WHERE metric_name IN ('Database Time Per Sec', 'Database Wait Time Ratio')
AND group_id = 2
AND end_time >= SYSDATE - INTERVAL '60' MINUTE
GROUP BY TO_CHAR(end_time, 'hh24:mi:ss')
ORDER BY sample_time
)
SELECT sample_time
, 'Wait' metric_name
, ROUND(aas_value*wait_ratio, 4) active_sessions
FROM wait
;
SAMPLE_TIME METRIC_NAME ACTIVE_SESSIONS
----------- ----------- ---------------
......
14:07:29 Wait .5928
......
60 rows selected.
傻眼了,和先前的EMCC中显示的数据完全不一样!!!
失败是成功之母。或者说,不经一番寒彻骨,怎得梅花扑鼻香。让我们换位思考一下,既然User I/O是一种等待类别(CPU不是),那么这个Wait会不会是其余所有等待类别的总和?另外,这是我们从视图V$SYSTEM_WAIT_CLASS中查询到的所有等待类别:
SELECT DISTINCT wait_class
FROM v$system_wait_class
ORDER BY 1
;
WAIT_CLASS
---------------
Administrative
Application
Commit
Concurrency
Configuration
Idle
Network
Other
Scheduler
System I/O
User I/O
11 rows selected.
基于这个猜想,让我们去探索一番:
-- 'Wait' is fairly precise to the legend 'Wait' from the "Active Sessions Per Activity Class" Graph of EMCC 13.5.
SET LINESIZE 200
SET PAGESIZE 100
COLUMN sample_time FORMAT a11
COLUMN metric_name FORMAT a11
COLUMN active_sessions FORMAT 999,999.9999
SELECT TO_CHAR(wcmh.end_time, 'hh24:mi:ss') sample_time
, 'Wait' metric_name
, SUM(ROUND(wcmh.time_waited/wcmh.intsize_csec, 4)) active_sessions
FROM v$waitclassmetric_history wcmh
, v$system_wait_class swc
WHERE wcmh.wait_class_id = swc.wait_class_id
AND (swc.wait_class NOT IN ('Idle', 'User I/O'))
AND wcmh.end_time >= SYSDATE - INTERVAL '60' MINUTE
GROUP BY TO_CHAR(wcmh.end_time, 'hh24:mi:ss')
ORDER BY sample_time
;
SAMPLE_TIME METRIC_NAME ACTIVE_SESSIONS
----------- ----------- ---------------
......
14:07:29 Wait 2.2382
......
60 rows selected.
果不其然,这回终于和EMCC上显示的数据(请查看上一张屏幕截图)相同了,瞬间会不会有一种欣喜的感觉?哈哈。。。
用公用表表达式整合CPU、User I/O和Wait
至此,我们已经把三个类别的SQL查询都写出来了,那就用“WITH ... AS ()”整合成一个完整的吧,请看下面(附带查询数据):
-- At this moment 'CPU', 'User I/O' and 'Wait' are all same as the "Active Sessions Per Activity Class" Graph from EMCC 13.5. Congrats!!!
-- Note: using the column 'time_waited' (rather than 'time_waited_fg') of view "v$waitclassmetric_history" to acquire 'User I/O' and 'Wait'.
-- Active Sessions Per Activity Class (CPU, User I/O and Wait) from EMCC 13.5 in Last 1 Hour.
SET LINESIZE 200
SET PAGESIZE 200
COLUMN sample_time FORMAT a11
COLUMN metric_name FORMAT a11
COLUMN active_sessions FORMAT 999,999.9999
WITH
cpu AS
(
SELECT TO_CHAR(end_time, 'hh24:mi:ss') sample_time
, DECODE(metric_name, 'CPU Usage Per Sec', 'CPU') metric_name
, ROUND(value/1e2, 4) active_sessions
FROM v$sysmetric_history
WHERE metric_name = 'CPU Usage Per Sec'
AND group_id = 2
AND end_time >= SYSDATE - INTERVAL '60' MINUTE
ORDER BY sample_time
),
user_io AS
(
SELECT TO_CHAR(wcmh.end_time, 'hh24:mi:ss') sample_time
, swc.wait_class metric_name
, ROUND(wcmh.time_waited/wcmh.intsize_csec, 4) active_sessions
FROM v$waitclassmetric_history wcmh
, v$system_wait_class swc
WHERE wcmh.wait_class_id = swc.wait_class_id
AND swc.wait_class = 'User I/O'
AND wcmh.end_time >= SYSDATE - INTERVAL '60' MINUTE
ORDER BY sample_time
),
wait AS
(
SELECT TO_CHAR(wcmh.end_time, 'hh24:mi:ss') sample_time
, 'Wait' metric_name
, SUM(ROUND(wcmh.time_waited/wcmh.intsize_csec, 4)) active_sessions
FROM v$waitclassmetric_history wcmh
, v$system_wait_class swc
WHERE wcmh.wait_class_id = swc.wait_class_id
AND (swc.wait_class NOT IN ('Idle', 'User I/O'))
AND wcmh.end_time >= SYSDATE - INTERVAL '60' MINUTE
GROUP BY TO_CHAR(wcmh.end_time, 'hh24:mi:ss')
ORDER BY sample_time
)
SELECT * FROM cpu
UNION ALL
SELECT * FROM user_io
UNION ALL
SELECT * FROM wait
;
SAMPLE_TIME METRIC_NAME ACTIVE_SESSIONS
----------- ----------- ---------------
......
14:07:29 CPU .8005
......
14:07:29 User I/O .0064
......
14:07:29 Wait 2.2382
......
180 rows selected.
用Oracle SQL Developer 21.2可视化
将这个XML文件(Active_Sessions_Per_Activity_Class.xml)导入(具体步骤:1. 下载刚提到的XML文件到本地电脑;2. 在SQL Developer中右击用户自定义报告,然后选择打开报告,去选择刚才的XML文件即可完成导入操作)到我的SQL Developer 21.2的用户自定义报告当中,然后连接相应的数据库,就可以看到下面的可视化图表:
最近1分钟的每个活动类的活动会话
完整的SQL查询代码
-- Active Sessions Per Activity Class (CPU, User I/O and Wait) from EMCC 13.5 in Last 1 Minute.
SET LINESIZE 200
SET PAGESIZE 10
COLUMN sample_time FORMAT a11
COLUMN metric_name FORMAT a11
COLUMN active_sessions FORMAT 999,999.99
WITH
cpu AS
(
SELECT TO_CHAR(end_time, 'hh24:mi:ss') sample_time
, DECODE(metric_name, 'CPU Usage Per Sec', 'CPU') metric_name
, ROUND(value/1e2, 2) active_sessions
FROM v$sysmetric
WHERE metric_name = 'CPU Usage Per Sec'
AND group_id = 2
ORDER BY sample_time
),
user_io AS
(
SELECT TO_CHAR(end_time, 'hh24:mi:ss') sample_time
, swc.wait_class metric_name
, ROUND(wcm.time_waited/wcm.intsize_csec, 2) active_sessions
FROM v$waitclassmetric wcm
, v$system_wait_class swc
WHERE wcm.wait_class_id = swc.wait_class_id
AND swc.wait_class = 'User I/O'
ORDER BY sample_time
),
wait AS
(
SELECT TO_CHAR(end_time, 'hh24:mi:ss') sample_time
, 'Wait' metric_name
, SUM(ROUND(wcm.time_waited/wcm.intsize_csec, 2)) active_sessions
FROM v$waitclassmetric wcm
, v$system_wait_class swc
WHERE wcm.wait_class_id = swc.wait_class_id
AND (swc.wait_class NOT IN ('Idle', 'User I/O'))
GROUP BY TO_CHAR(end_time, 'hh24:mi:ss')
ORDER BY sample_time
)
SELECT * FROM cpu
UNION ALL
SELECT * FROM user_io
UNION ALL
SELECT * FROM wait
;
SAMPLE_TIME METRIC_NAME ACTIVE_SESSIONS
----------- ----------- ---------------
14:27:29 CPU .32
14:27:29 User I/O .00
14:27:29 Wait .59
来和EMCC的对比一下呗,嘿嘿!!!
那么,总的活动会话值是多少呢?在EMCC的“负载和容量”标签页中已经告诉了我们:
用Oracle SQL Developer 21.2可视化
因为在前一维度的可视化操作中导入的XML文件里已经包含了这一维度的图表可视化设置功能,所以我们找到相应的报告直接进行可视化,详见如下两图(1分钟的时间过的真得很快,我只能截取另一个时间点15:10,而不是前面的14:07,哈哈):
活动会话负载总览
在EMCC的首页有一个Oracle Load Map,它列出了每一个数据库的活动会话总览情况,如:CPU、IO和Wait,还是这三个分类呀,说来够巧的。但是也很奇怪,我观察了一段时间,发现它们三个值和总计值(它们的总和)始终没有任何变化。看来它不应该是最近1分钟的情况,因为最近1分钟的值总是会有变化的,有可能是最近1小时的平均值,这个我没有具体去研究,只是猜测,等抽空看看EM的官档中有关这个Load Map的解释,所以这里就只贴一个图吧。
获取图表的图例颜色
有的小伙伴可能会问,SQL Developer里的可视化图表的图例颜色为什么和EMCC图表的图例几乎一样,你是怎么做到的呢?这里,我用了一个小窍门儿。那就是将EMCC图表的每一个图例都截图保存成图片,然后在这个网站上传我保存的图片让其识别出相应的RGB颜色值(十六进制),接着我在SQL Developer的用户自定义报告中进行可视化设置时输入了对应图例的RGB颜色值(十六进制)。那么,这篇文章中用到的图表图例RGB颜色值是:
-- Each Legend Color from the Graph of "Active Sessions Per Activity Class" of EMCC 13.5.
--
-- CPU , #00CF30 -> RGB (0 , 207, 48 )
-- User I/O, #004CE6 -> RGB (0 , 76 , 230)
-- Wait , #FA5F00 -> RGB (250, 95 , 0 )
至此,可视化Oracle性能图表之“每个活动类的活动会话”篇今天就分享到这里结束了,其中最核心的SQL源代码您也可以从我的GitHub上查看,欢迎各路亲朋好友提出宝贵意见和建议,小编一定会再接再励,竭尽所能给大家奉献更多更具有价值的深度原创技术好文。
参考文章
- What is the SQL statement for the Active Sessions Per Activity Class from EMCC 13.5?
- Oracle CPU Time
- 如何获取图表的图例颜色
更新于 2021年11月30日 下午:
授人以鱼不如授人以渔,在AskTOM上Connor McDonald还没有解决我的困惑之前,我在最近的评论中这样回复道:
更新于 2021年12月9日 下午:
关于视图DBA_HIST_WAITCLASSMET_HISTORY的返回行为什么为0?后来Jonathan Lewis(世界级的Oracle大师)这样回复道,以下直接是翻译后的引用内容:
这一定是一个经过深思熟虑的编码决策,可能有一个隐藏参数(或对内部包的调用)改变了Oracle访问相关x$表的方式,但如果跟踪快照代码,您可以看到应该从x$表填充相关wrh$表的SQL语句,然后看到那里没有任何内容。
接着是Kyle Hailey的回复,也引用如下:
是的,我记得空的 dba_hist_waitclassmet_history 令人困惑。
我相信 dba_hist_waitclassmet_history 仅用于在违反某些限制时提醒条目。
我已经很久没有看这些东西了。
统计数据
DBA_HIST_SYSMETRIC_SUMMARY – 最大、最小、平均标准偏差
DBA_HIST_SYSSTAT(累计)
DBA_HIST_SYSMETRIC_HISTORY(警报)
等待
WAITCLASSMETRIC_HISTORY(警报)
DBA_HIST_SYSTEM_EVENT(累计)
文件IO
DBA_HIST_FILEMETRIC_HISTORY(警报)
DBA_HIST_FILESTATXS(累计)
随后,我也进行了相关的回复,内容为:
抱歉,DBA_HIST_FILEMETRIC_HISTORY 也返回了 0 行,Kyle! 我调用了 DBMS_METADATA.GET_DDL() 来检查定义的视图。
SET VERIFY OFF
SET LONG 1000000000
SET LINESIZE 200
SET PAGESIZE 200
PROMPT ==================
PROMPT Running on SYS schema
PROMPT ==================
SELECT DBMS_METADATA.get_ddl(UPPER('&object_type'), UPPER('&object_name'), UPPER('&owner_name')) FROM dual
/
Enter value for object_type: view
Enter value for object_name: dba_hist_waitclassmet_history
Enter value for owner_name: sys
DBMS_METADATA.GET_DDL(UPPER('VIEW'),UPPER('DBA_HIST_WAITCLASSMET_HISTORY'),UPPER
--------------------------------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "SYS"."DBA_HIST_WAITCLASSMET_HISTORY" ("SNAP_ID", "DBID", "INSTANCE_NUMBER", "WAIT_CLASS
_ID", "WAIT_CLASS", "BEGIN_TIME", "END_TIME", "INTSIZE", "GROUP_ID", "AVERAGE_WA
ITER_COUNT", "DBTIME_IN_WAIT", "TIME_WAITED", "WAIT_COUNT", "TIME_WAITED_FG", "W
AIT_COUNT_FG") AS
select em.snap_id, em.dbid, em.instance_number,
em.wait_class_id, wn.wait_class, begin_time, end_time, intsize,
group_id, average_waiter_count, dbtime_in_wait,
time_waited, wait_count, time_waited_fg, wait_count_fg
from wrm$_snapshot sn, WRH$_WAITCLASSMETRIC_HISTORY em,
(select wait_class_id, wait_class from wrh$_event_name
group by wait_class_id, wait_class) wn
where em.wait_class_id = wn.wait_class_id
and sn.snap_id = em.snap_id
and sn.dbid = em.dbid
and sn.instance_number = em.instance_number
and sn.status = 0
SQL> SELECT COUNT(*) FROM WRH$_WAITCLASSMETRIC_HISTORY;
COUNT(*)
-----------
0
SET VERIFY OFF
SET LONG 1000000000
SET LINESIZE 200
SET PAGESIZE 200
PROMPT ==================
PROMPT Running on SYS schema
PROMPT ==================
SELECT DBMS_METADATA.get_ddl(UPPER('&object_type'), UPPER('&object_name'), UPPER('&owner_name')) FROM dual
/
Enter value for object_type: view
Enter value for object_name: dba_hist_filemetric_history
Enter value for owner_name: sys
DBMS_METADATA.GET_DDL(UPPER('VIEW'),UPPER('DBA_HIST_FILEMETRIC_HISTORY'),UPPER('
--------------------------------------------------------------------------------
CREATE OR REPLACE FORCE VIEW "SYS"."DBA_HIST_FILEMETRIC_HISTORY" ("SNAP_ID", "DBID", "INSTANCE_NUMBER", "FILEID", "CR
EATIONTIME", "BEGIN_TIME", "END_TIME", "INTSIZE", "GROUP_ID", "AVGREADTIME", "AV
GWRITETIME", "PHYSICALREAD", "PHYSICALWRITE", "PHYBLKREAD", "PHYBLKWRITE") AS
select fm.snap_id, fm.dbid, fm.instance_number,
fileid, creationtime, begin_time,
end_time, intsize, group_id, avgreadtime, avgwritetime,
physicalread, physicalwrite, phyblkread, phyblkwrite
from wrm$_snapshot sn, WRH$_FILEMETRIC_HISTORY fm
where sn.snap_id = fm.snap_id
and sn.dbid = fm.dbid
and sn.instance_number = fm.instance_number
and sn.status = 0
SQL> SELECT COUNT(*) FROM WRH$_FILEMETRIC_HISTORY;
COUNT(*)
-----------
0