下面的查询按小时输出数据库中所有表的“逻辑读取”。每个 snap_id 在一小时的时间范围内。
SELECT
a.snap_id,
e.begin_interval_time,
e.end_interval_time,
owner as schema,
object_name AS table_name,
logical_reads_delta as logical_reads_per_table
FROM
dba_hist_seg_stat a,
dba_hist_seg_stat_obj b,
dba_hist_sqlstat c,
dba_hist_snapshot e
WHERE
owner != 'SYS'
and owner != 'SYSTEM'
and a.snap_id = c.snap_id
and c.snap_id = e.snap_id
AND a.obj# = b.obj#
AND a.dataobj# = b.dataobj#
AND object_type = 'TABLE'
ORDER BY
a.snap_id;
输出:
snap_id begin_interval_time end_interval_time schema table_name logical_reads_per_table
------- ------------------------- ------------------------- ------ ----------------- -----------------------
8414 06/28/2012 7:00:11.006 AM 06/28/2012 8:00:16.540 AM WV90 WVT_WVPERFORATION 50288
8414 06/28/2012 7:00:11.006 AM 06/28/2012 8:00:16.540 AM WV90 WVT_WVPERFORATION 50288
8414 06/28/2012 7:00:11.006 AM 06/28/2012 8:00:16.540 AM WV90 WVT_WVPERFORATION 50288
8415 06/28/2012 8:00:16.540 AM 06/28/2012 9:00:21.516 AM EG USER_GROUP_LIST 105328
8415 06/28/2012 8:00:16.540 AM 06/28/2012 9:00:21.516 AM EG USER_GROUP_LIST 105328
我认为存在重复,因为每个表都有唯一的 SQL_ID(没有显示)。
我需要做一个左连接(我认为)和分组以获得我真正想要的指定输出。
我希望输出是这样的......
SNAP_ID | BEGIN_INTERVAL_TIME | END_INTERVAL_TIME ->>> OWNER | OBJECT_NAME | LOGICAL_READS_DELTA (logical reads in the time frame)
想法?