Oracle Log Miner - 操作大小

时间:2015-10-22 15:36:43

标签: oracle

最初的一些背景信息:我目前正在分析使用NServiceBus的.Net应用程序对Oracle数据库的负载。我们在运行应用程序时观察到高重做日志活动,因此 - 大量的归档日志(我们在归档日志模式下有数据库)。我们已经使用Toad Logminer找出导致它的原因,不幸的是许多操作都是UNSUPPORTED类型。我认为这是因为使用了安全文件类型的LOB。但是我已经深入数据库到Logminer视图:v $ logmnr_contents看到有比Toad的Logminer更多的列。

我需要的是重做中每个操作的大小。到目前为止,这是我的查询:

SELECT TIMESTAMP,
       RBABYTE,
       SEG_OWNER,
       SEG_NAME,
       TABLE_NAME,
       SEG_TYPE,
       SEG_TYPE_NAME,
       TABLE_SPACE,
       ROW_ID,
       OPERATION,
       SQL_REDO
  FROM V$LOGMNR_CONTENTS
 WHERE 1 = 1 AND OPERATION = 'UNSUPPORTED'

我不确定RBABYTE是否使用正确值或计算更复杂,对我来说它看起来像包括LOB的记录大小。 Oracle的文档说它是“块内的RBA字节偏移”,但这还不够。 请指教。

1 个答案:

答案 0 :(得分:2)

尝试此查询:

with t1 as
        (select rs_id,
                ssn,
                rbablk,
                rbabyte,
                rbablk * 512 + rbabyte curpos,
                lead (rbablk * 512 + rbabyte, 1, rbablk * 512 + rbabyte)
                   over (partition by substr (rs_id, 1, 9)order by
                            rbasqn,
                            rbablk,
                            rbabyte,
                            scn,
                            redo_value)
                   nextpos,
                  lead (rbablk * 512 + rbabyte, 1, rbablk * 512 + rbabyte)
                     over (partition by substr (rs_id, 1, 9)order by
                              rbasqn,
                              rbablk,
                              rbabyte,
                              scn,
                              redo_value)
                - (rbablk * 512 + rbabyte)
                   redo_size,
                operation,
                case
                   when operation = 'INTERNAL' and data_obj# != 0 then
                      (select t0.owner
                         from dba_objects t0
                        where t0.object_id = t1.data_obj#)
                   else
                      seg_owner
                end
                   seg_owner,
                case
                   when operation = 'INTERNAL' and data_obj# != 0 then
                      (select t0.object_name nome
                         from dba_objects t0
                        where t0.object_id = t1.data_obj#)
                   else
                      seg_name
                end
                   seg_name,
                sql_redo,
                redo_value,
                client_id,
                timestamp
           from v$logmnr_contents t1)
  select rs_id,
         ssn,
         rbablk,
         rbabyte,
         curpos,
         nextpos,
         redo_size,
         seg_owner,
         seg_name,
         operation,
         sql_redo
    from t1
order by substr (rs_id, 1, 9),
         ssn,
         rbablk,
         rbabyte,
         redo_value