2 changed files with 11 additions and 12 deletions
@ -1,15 +1,14 @@ |
|||||||
-- List active indexing sessions and their progress |
-- List active indexing sessions and their progress |
||||||
SELECT p.pid |
SELECT p.pid |
||||||
, date_trunc('second',now() - a.xact_start) AS dur |
, date_trunc('second',now() - a.xact_start) AS duration |
||||||
, coalesce(wait_event_type ||'.'|| wait_event, 'f') AS wait |
, p.datname AS database |
||||||
, p.datname |
, p.index_relid::regclass AS index |
||||||
, p.index_relid::regclass AS ind |
, pg_size_pretty(pg_total_relation_size(index_relid)) || ' / ' || coalesce(pg_size_pretty(pg_total_relation_size((SELECT DISTINCT indexrelid FROM pg_locks l JOIN pg_index i ON l.relation = i.indexrelid WHERE l.pid = p.pid AND l.locktype = 'relation' AND i.indexrelid != p.index_relid))), '-') AS "new / old size" |
||||||
, round(pg_total_relation_size(index_relid)/1024.0/1024) AS ind_ttl_mb |
|
||||||
, p.command, p.phase |
, p.command, p.phase |
||||||
|
, CASE WHEN blocks_total > 0 THEN format('%s%% of %s', round(blocks_done::numeric / blocks_total * 100, 1), blocks_total) END AS blocks |
||||||
|
, CASE WHEN tuples_total > 0 THEN format('%s%% of %s', round(tuples_done::numeric / tuples_total * 100, 1), tuples_total) END AS tuples |
||||||
|
, (SELECT COUNT(*) FROM pg_stat_activity a2 where a2.query = a.query) AS workers |
||||||
, CASE WHEN lockers_total > lockers_done AND p.phase ~ 'waiting' |
, CASE WHEN lockers_total > lockers_done AND p.phase ~ 'waiting' |
||||||
THEN format('%s ( %s / %s )', current_locker_pid, lockers_done, lockers_total) END AS waiting |
THEN format('%s ( %s / %s )', current_locker_pid, lockers_done, lockers_total) END AS waiting |
||||||
, CASE WHEN blocks_total > 0 THEN format('%s%% of %s', round(blocks_done::numeric / blocks_total * 100), blocks_total) END AS blocks |
, coalesce(wait_event_type ||'.'|| wait_event, 'f') AS wait_event |
||||||
, CASE WHEN tuples_total > 0 THEN format('%s%% of %s', round(tuples_done::numeric / tuples_total * 100), tuples_total) END AS tuples |
FROM pg_stat_progress_create_index p JOIN pg_stat_activity a using (pid) ORDER BY duration DESC; |
||||||
, CASE WHEN partitions_total > 0 THEN format('%s%% of %s', round(partitions_done::numeric / partitions_total * 100), partitions_total) END AS partitions |
|
||||||
FROM pg_stat_progress_create_index p JOIN pg_stat_activity a using (pid) ORDER BY dur DESC; |
|
||||||
|
|
||||||
Loading…
Reference in new issue