Hello,
Please find attached updated patch with an interface to calculate command progress in pgstat.c. This interface currently implements VACUUM progress tracking .
A column named percent_complete has been added in pg_stat_activity to report progress.
VACUUM calls the progress calculation interface periodically at an interval specified by pgstat_track_progress GUC in ms.
Progress calculation can be disabled by setting pgstat_track_progress as -1.
Remaining_time for VACUUM is not included in current patch to avoid cluttering pg_stat_activity with too many columns.
But the estimate as seen from previous implementation seems reasonable enough to be included in progress information , may be as an exclusive view for vacuum progress information.
GUC parameter 'pgstat_track_progress' is currently PGC_SUSET in line with 'track_activities' GUC parameter. Although IMO, pgstat_track_progress can be made PGC_USERSET in order to provide more flexibility to any user to enable/disable progress calculation provided progress is tracked only if track_activities GUC parameter is enabled.
In this patch, index scans are not taken into account for progress calculation as of now .
Thank you,
Rahila Syed.