Skip to main content
Version: 2.x

pg_stat_progress_create_index

pg_stat_progress_create_index

pg_stat_progress_create_index is a system view that shows real-time progress for ongoing CREATE INDEX or REINDEX operations in the current database.

This view displays detailed status information for each backend process building an index, including the current execution phase, the number of tuples processed, blocks scanned, and more. Once the operation completes, the corresponding entries are automatically removed from the view.

In Apache Cloudberry, this view also supports AO (Append-Optimized) tables and can be used to observe the phase-wise progress of index creation on such tables.

Typical use cases include:

  • Monitoring index creation or rebuild operations in real time.
  • Analyzing performance bottlenecks of long-running CREATE INDEX or REINDEX commands.
  • Checking if any index operations are currently consuming system resources.
  • Correlating with pg_stat_activity to trace backend process details.

Example queries:

-- Views all ongoing index creation tasks
SELECT * FROM pg_stat_progress_create_index;

-- Views index progress for a specific table
SELECT * FROM pg_stat_progress_create_index
WHERE relid = 'ao_test'::regclass;

Field descriptions

FieldDescription
gp_segment_idID of the segment where this entry resides. Only applicable in a distributed environment.
pidProcess ID of the backend. Can be joined with pg_stat_activity for session details.
datidOID of the database, corresponding to pg_database.oid.
datnameName of the database.
relidOID of the table being indexed, corresponding to pg_class.oid.
index_relidOID of the index being built.
commandCommand being executed: CREATE INDEX or REINDEX.
phaseCurrent phase of execution, for example:
initializing: Initialization phase
scanning heap: Scanning table data
sorting: Sorting phase
building index: loading tuples in tree: Building index structure
waiting for locks: Waiting for table or metadata locks
lockers_totalTotal number of sessions holding conflicting locks (if any).
lockers_doneNumber of sessions that have released their locks.
current_locker_pidProcess ID of the session currently holding the lock (if waiting).
blocks_totalTotal number of data blocks to scan (may be 0 if unknown or not started).
blocks_doneNumber of data blocks already scanned.
tuples_totalEstimated total number of tuples to process (if available).
tuples_doneNumber of tuples already processed.
partitions_totalTotal number of partitions (if applicable).
partitions_doneNumber of partitions already processed (if applicable).
note
  • This view only shows currently running index operations. Entries disappear once the operation completes.

  • For small tables, index creation may complete instantly, and the view might return no rows.

  • To better observe progress, try creating an index on a large table or use complex columns (for example, large text) to slow down execution.

  • Progress is also reported when building indexes on AO (Append-Optimized) tables.

  • You can join this view with pg_stat_activity using the pid field.

    SELECT a.usename, a.query, p.phase, p.blocks_done, p.blocks_total
    FROM pg_stat_activity a
    JOIN pg_stat_progress_create_index p ON a.pid = p.pid;