Add progress tracking during tuple copy phase#477
Open
dreadushka wants to merge 2 commits intoreorg:masterfrom
Open
Add progress tracking during tuple copy phase#477dreadushka wants to merge 2 commits intoreorg:masterfrom
dreadushka wants to merge 2 commits intoreorg:masterfrom
Conversation
added 2 commits
February 8, 2026 18:24
Create repack.track_insert_<oid> sequence to count copied rows and expose progress via get_progress_all().
…uery The RETURNING clause for progress tracking sequence was incorrectly placed before ORDER BY in INSERT ... SELECT statements, causing syntax errors. Moved RETURNING to the end of the query after ORDER BY processing in pg_repack.c and removed it from the base query template in pg_repack.sql.in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Progress tracking for long-running repacks
The problem
Repacking multi-terabyte tables can take days. Currently, there is no reliable way to determine whether the operation is progressing or stuck. As a result, teams are forced to:
What this adds
A progress counter that increments for every row copied during the
COPYphase. It uses a dedicated per-table sequence (repack.track_insert_<oid>). No additional locks or scans are required.Progress is exposed via a simple function:
Why it helps
We used this feature during holiday maintenance on tables exceeding 12 TB. Being able to state "we're at 73% after 36 hours of work" allowed us to:
Compatibility
Fully backward compatible—existing repack workflows remain unchanged. Cleanup occurs automatically through the existing
repack_drop()mechanism.This small improvement makes long-running repack operations observable without adding operational complexity.