处理正在进行的SQL语句的行数

时间:2015-06-25 09:44:07

标签: oracle monitor long-running-processes

我们从一个Oracle数据库复制大表并将它们合并到另一个数据库。因此,我们有非常长的运行插入语句。

我想知道已经处理了很多行。我知道这可以通过Oracle完成,因为PL / SQL-Developer可以在HTML报告中显示统计信息。

我尝试了以下SQL:

-- currently executing SQLs
select sm.SID, sm.SQL_ID, sm.STATUS, sm.SQL_TEXT, sm.LAST_REFRESH_TIME, sm.FIRST_REFRESH_TIME, 
       sp.OPERATION, sp.TIMESTAMP, sp.CARDINALITY as EST_ROWS,
       sp.OBJECT_OWNER, sp.OBJECT_NAME, sp.OBJECT_TYPE, sp.COST, sp.BYTES, sp.CPU_COST
  from V$SQL_MONITOR sm 
  inner join V$SQL_PLAN sp
    on sm.SQL_ID = sp.SQL_ID
 where sm.STATUS = 'EXECUTING'
 order by sm.LAST_REFRESH_TIME desc, sp.DEPTH;

我已经尝试了字段V$SQLSTATS.ROWS_PROCESSEDV$SESSTAT.VALUE(使用STATISTIC#= 308),但没有显示当前处理的行数。

有谁知道,如何在Oracle 11g中确定特定SQL语句的当前处理行数?

提前致谢。

1 个答案:

答案 0 :(得分:0)

See comment above, here's an example from www.dba-oracle.com showing amount of work done so far:

select
   sid,
   message
from
   v$session_longops
where
   sid = 13
order by
   start_time;

Here is a sample of the output, showing the progress of a long running CREATE INDEX statement.

SID MESSAGE
--- -------------------------------------------------------------------
 11 Table Scan:  CUST.PK_IDX: 732 out of 243260 Blocks done
相关问题