長時間実行中の操作の進捗を表示
Oracle
SELECT sid, serial#, opname, target, sofar, totalwork,
ROUND(sofar / NULLIF(totalwork,0) * 100, 2) AS pct_done,
time_remaining, elapsed_seconds
FROM v$session_longops
WHERE totalwork > 0 AND sofar < totalwork
ORDER BY start_time;v$session_longops は、6 秒を超えて実行されている操作の進捗率と残り時間(time_remaining)を示す。
PostgreSQL
SELECT pid, phase, heap_blks_total, heap_blks_scanned,
ROUND(heap_blks_scanned::numeric / NULLIF(heap_blks_total,0) * 100, 2) AS pct
FROM pg_stat_progress_vacuum;
-- Others: pg_stat_progress_create_index, _cluster, _analyze, _copy, _basebackuppg_stat_progress_* ビューは VACUUM、CREATE INDEX、CLUSTER、ANALYZE、COPY 操作の進捗を報告する。
MySQL
SELECT t.processlist_id, st.event_name, st.work_completed, st.work_estimated,
ROUND(st.work_completed / NULLIF(st.work_estimated,0) * 100, 2) AS pct
FROM performance_schema.events_stages_current st
JOIN performance_schema.threads t ON t.thread_id = st.thread_id
WHERE st.work_estimated > 0;ステージのインストルメンテーションが有効な場合、events_stages_current は work_completed/work_estimated で進捗を示す(例: ALTER TABLE)。
SQL Server
SELECT session_id, command, percent_complete,
DATEADD(ms, estimated_completion_time, GETDATE()) AS est_finish,
total_elapsed_time / 1000 AS elapsed_sec
FROM sys.dm_exec_requests
WHERE percent_complete > 0
ORDER BY percent_complete;sys.dm_exec_requests.percent_complete は BACKUP、RESTORE、DBCC、インデックスの再構築などの操作の進捗率を示す。
MongoDB
db.currentOp({ "active": true, "secs_running": { "$gte": 3 } })db.currentOp の出力では、長時間実行中の操作と、インデックス作成の場合は 'progress' フィールド(done/total)が進捗を示す。
Redis
INFO persistence
# Keys: rdb_bgsave_in_progress, aof_rewrite_in_progress, rdb_last_bgsave_status, loading, loading_loaded_percINFO persistence セクションは、RDB/AOF の保存や書き換えが進行中かどうかと、ロードの進捗率を報告する。
Elasticsearch
GET _tasks?detailed=true&actions=*reindex,*update/byquery,*delete/byquery
# For recovery/shard relocation: GET _cat/recovery?v&active_only=true_tasks?detailed は長時間実行タスク(reindex、update_by_query)の状態を、_cat/recovery はアクティブなシャードリカバリの進捗を示す。