[英]Tracking drop column progress in Oracle
我在一個巨大的表(1.8 TB大小)上的Oracle中發表了以下聲明:
alter table drop unused columns checkpoint
它已經運行了將近10天,由於內存不足而崩潰了幾次。
我通過以下方式恢復了它:
alter table drop columns continue
如何跟蹤進度並可能估算完成時間?
我嘗試查詢v $ session_longops,但是此會話沒有任何記錄。
我知道這是一個古老的問題,但是鑒於實際上沒有人回答過,因此這是我遇到相同問題時想到的:
select v.*, to_char(100*"Processed"/"# of Blocks", '990D000000') "% Complete" from (select sid, serial#, status, event, p1text, p1, p2text, p2, p3text, p3, x.segment_name, x.extent_id, (select sum(case when p2 not between block_id and block_id + blocks - 1 then blocks else p2 - block_id end) from dba_extents x2 where x2.segment_name = x.segment_name and extent_id <= x.extent_id) "Processed", (select sum(blocks) from dba_extents where segment_name = x.segment_name) "# of Blocks" from v$session s left join dba_extents x on p1 = file_id and p2 between block_id and block_id + blocks - 1 where (sid, serial#) in ((15,40610)) ) v
基本上,我是從進行刪除操作的會話的wait事件中獲取P2值(塊號),並確定進程在表的段列表中的位置。
這里假設還有一些工作留給讀者
人們可能還只能查看會話所占的程度與該段中的程度總數之間的關系,從而大致估計進度。
希望其他人也能找到幫助,即使只是作為建立更好解決方案的面包屑。
干杯
上面的好查詢。 我對查詢做了一些修改:
select
v.*,
Round(100*"Processed"/"# of Blocks", 2) "% Complete"
from (
select
sid,
serial#,
status,
event,
p1text,
p1,
p2text,
p2,
p3text,
p3,
x.segment_name,
x.partition_name,
x.extent_id,
( select
sum(
case
when p2.partition_position < p.partition_position
then x2.blocks
when ( x2.partition_name is null or
p2.partition_position = p.partition_position) and
x2.file_id < x.file_id
then x2.blocks
when ( x2.partition_name is null or
p2.partition_position = p.partition_position) and
x2.file_id = x.file_id and
x2.block_id < x.block_id
then x2.blocks
when ( x2.partition_name is null or
p2.partition_position = p.partition_position) and
x2.file_id = x.file_id and
x2.block_id = x.block_id and
s.p2 < x2.block_id + x2.blocks
then s.p2 - x2.block_id
end
)
from DBA_EXTENTS x2
left join DBA_TAB_PARTITIONS p2
on p2.table_owner = x2.owner and
p2.table_name = x2.segment_name and
p2.partition_name = x2.partition_name
where x2.segment_name = x.segment_name
) as "Processed",
( select
sum(x2.blocks)
from DBA_EXTENTS x2
where x2.segment_name = x.segment_name
) as "# of Blocks"
from V$SESSION s
left join DBA_EXTENTS x
on s.p1 = x.file_id and
s.p2 between x.block_id and x.block_id + x.blocks - 1
left join DBA_TAB_PARTITIONS p
on p.table_owner = x.owner and
p.table_name = x.segment_name and
p.partition_name = x.partition_name
where
--(sid, serial#) in ((84,23431)) or
s.event = 'db file scattered read'
) v
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.