SELECT
pid,
datname,
relid::regclass as table_name,
index_relid::regclass as index_name,
command,
phase,
blocks_total,
blocks_done,
tuples_total,
tuples_done,
partitions_total,
partitions_done,
round(100.0 * blocks_done / NULLIF(blocks_total, 0), 2) as percent_complete
FROM pg_stat_progress_create_index;
This shows the current phase of index creation (like "building index", "performing final sort", etc.) along with progress metrics.
Check active processes
You can also see if the index creation is still running by checking active processes:
SELECT
pid,
state,
query_start,
now() - query_start as duration,
query
FROM pg_stat_activity
WHERE query ILIKE '%CREATE%INDEX%'
AND state = 'active';
Monitor locks
Concurrent index creation takes specific locks that you can monitor:
SELECT
l.pid,
l.mode,
l.granted,
c.relname as table_name
FROM pg_locks l
JOIN pg_class c ON l.relation = c.oid
WHERE l.mode = 'ShareUpdateExclusiveLock'
AND c.relkind = 'r';
Check system activity
For a broader view of what's happening on your system:
SELECT
pid,
usename,
application_name,
state,
wait_event_type,
wait_event,
query_start,
query
FROM pg_stat_activity
WHERE state != 'idle';
The pg_stat_progress_create_index view is your best bet for detailed progress information, as it shows exactly which phase the index creation is in and how much work has been completed.