@@ -344,6 +344,14 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
344344 </entry>
345345 </row>
346346
347+ <row>
348+ <entry><structname>pg_stat_progress_cluster</structname><indexterm><primary>pg_stat_progress_cluster</primary></indexterm></entry>
349+ <entry>One row for each backend running
350+ <command>CLUSTER</command> or <command>VACUUM FULL</command>, showing current progress.
351+ See <xref linkend='cluster-progress-reporting'/>.
352+ </entry>
353+ </row>
354+
347355 </tbody>
348356 </tgroup>
349357 </table>
@@ -3394,9 +3402,9 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
33943402
33953403 <para>
33963404 <productname>PostgreSQL</productname> has the ability to report the progress of
3397- certain commands during command execution. Currently, the only command
3398- which supports progress reporting is <command>VACUUM</command>. This may be
3399- expanded in the future.
3405+ certain commands during command execution. Currently, the only commands
3406+ which support progress reporting are <command>VACUUM</command> and
3407+ <command>CLUSTER</command>. This may be expanded in the future.
34003408 </para>
34013409
34023410 <sect2 id="vacuum-progress-reporting">
@@ -3408,9 +3416,11 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
34083416 one row for each backend (including autovacuum worker processes) that is
34093417 currently vacuuming. The tables below describe the information
34103418 that will be reported and provide information about how to interpret it.
3411- Progress reporting is not currently supported for <command>VACUUM FULL</command>
3412- and backends running <command>VACUUM FULL</command> will not be listed in this
3413- view.
3419+ Progress for <command>VACUUM FULL</command> commands is reported via
3420+ <structname>pg_stat_progress_cluster</structname>
3421+ because both <command>VACUUM FULL</command> and <command>CLUSTER</command>
3422+ rewrite the table, while regular <command>VACUUM</command> only modifies it
3423+ in place. See <xref linkend='cluster-progress-reporting'/>.
34143424 </para>
34153425
34163426 <table id="pg-stat-progress-vacuum-view" xreflabel="pg_stat_progress_vacuum">
@@ -3587,6 +3597,183 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
35873597 </tgroup>
35883598 </table>
35893599
3600+ </sect2>
3601+
3602+ <sect2 id="cluster-progress-reporting">
3603+ <title>CLUSTER Progress Reporting</title>
3604+
3605+ <para>
3606+ Whenever <command>CLUSTER</command> or <command>VACUUM FULL</command> is
3607+ running, the <structname>pg_stat_progress_cluster</structname> view will
3608+ contain a row for each backend that is currently running either command.
3609+ The tables below describe the information that will be reported and
3610+ provide information about how to interpret it.
3611+ </para>
3612+
3613+ <table id="pg-stat-progress-cluster-view" xreflabel="pg_stat_progress_cluster">
3614+ <title><structname>pg_stat_progress_cluster</structname> View</title>
3615+ <tgroup cols="3">
3616+ <thead>
3617+ <row>
3618+ <entry>Column</entry>
3619+ <entry>Type</entry>
3620+ <entry>Description</entry>
3621+ </row>
3622+ </thead>
3623+
3624+ <tbody>
3625+ <row>
3626+ <entry><structfield>pid</structfield></entry>
3627+ <entry><type>integer</type></entry>
3628+ <entry>Process ID of backend.</entry>
3629+ </row>
3630+ <row>
3631+ <entry><structfield>datid</structfield></entry>
3632+ <entry><type>oid</type></entry>
3633+ <entry>OID of the database to which this backend is connected.</entry>
3634+ </row>
3635+ <row>
3636+ <entry><structfield>datname</structfield></entry>
3637+ <entry><type>name</type></entry>
3638+ <entry>Name of the database to which this backend is connected.</entry>
3639+ </row>
3640+ <row>
3641+ <entry><structfield>relid</structfield></entry>
3642+ <entry><type>oid</type></entry>
3643+ <entry>OID of the table being clustered.</entry>
3644+ </row>
3645+ <row>
3646+ <entry><structfield>command</structfield></entry>
3647+ <entry><type>text</type></entry>
3648+ <entry>
3649+ The command that is running. Either CLUSTER or VACUUM FULL.
3650+ </entry>
3651+ </row>
3652+ <row>
3653+ <entry><structfield>phase</structfield></entry>
3654+ <entry><type>text</type></entry>
3655+ <entry>
3656+ Current processing phase. See <xref linkend='cluster-phases' />.
3657+ </entry>
3658+ </row>
3659+ <row>
3660+ <entry><structfield>cluster_index_relid</structfield></entry>
3661+ <entry><type>bigint</type></entry>
3662+ <entry>
3663+ If the table is being scanned using an index, this is the OID of the
3664+ index being used; otherwise, it is zero.
3665+ </entry>
3666+ </row>
3667+ <row>
3668+ <entry><structfield>heap_tuples_scanned</structfield></entry>
3669+ <entry><type>bigint</type></entry>
3670+ <entry>
3671+ Number of heap tuples scanned.
3672+ This counter only advances when the phase is
3673+ <literal>seq scanning heap</literal>,
3674+ <literal>index scanning heap</literal>
3675+ or <literal>writing new heap</literal>.
3676+ </entry>
3677+ </row>
3678+ <row>
3679+ <entry><structfield>heap_tuples_written</structfield></entry>
3680+ <entry><type>bigint</type></entry>
3681+ <entry>
3682+ Number of heap tuples written.
3683+ This counter only advances when the phase is
3684+ <literal>seq scanning heap</literal>,
3685+ <literal>index scanning heap</literal>
3686+ or <literal>writing new heap</literal>.
3687+ </entry>
3688+ </row>
3689+ <row>
3690+ <entry><structfield>heap_blks_total</structfield></entry>
3691+ <entry><type>bigint</type></entry>
3692+ <entry>
3693+ Total number of heap blocks in the table. This number is reported
3694+ as of the beginning of <literal>seq scanning heap</literal>.
3695+ </entry>
3696+ </row>
3697+ <row>
3698+ <entry><structfield>heap_blks_scanned</structfield></entry>
3699+ <entry><type>bigint</type></entry>
3700+ <entry>
3701+ Number of heap blocks scanned. This counter only advances when the
3702+ phase is <literal>seq scanning heap</literal>.
3703+ </entry>
3704+ </row>
3705+ <row>
3706+ <entry><structfield>index_rebuild_count</structfield></entry>
3707+ <entry><type>bigint</type></entry>
3708+ <entry>
3709+ Number of indexes rebuilt. This counter only advances when the phase
3710+ is <literal>rebuilding index</literal>.
3711+ </entry>
3712+ </row>
3713+ </tbody>
3714+ </tgroup>
3715+ </table>
3716+
3717+ <table id="cluster-phases">
3718+ <title>CLUSTER and VACUUM FULL phases</title>
3719+ <tgroup cols="2">
3720+ <thead>
3721+ <row>
3722+ <entry>Phase</entry>
3723+ <entry>Description</entry>
3724+ </row>
3725+ </thead>
3726+
3727+ <tbody>
3728+ <row>
3729+ <entry><literal>initializing</literal></entry>
3730+ <entry>
3731+ The command is preparing to begin scanning the heap. This phase is
3732+ expected to be very brief.
3733+ </entry>
3734+ </row>
3735+ <row>
3736+ <entry><literal>seq scanning heap</literal></entry>
3737+ <entry>
3738+ The command is currently scanning the table using a sequential scan.
3739+ </entry>
3740+ </row>
3741+ <row>
3742+ <entry><literal>index scanning heap</literal></entry>
3743+ <entry>
3744+ <command>CLUSTER</command> is currently scanning the table using an index scan.
3745+ </entry>
3746+ </row>
3747+ <row>
3748+ <entry><literal>sorting tuples</literal></entry>
3749+ <entry>
3750+ <command>CLUSTER</command> is currently sorting tuples.
3751+ </entry>
3752+ </row>
3753+ <row>
3754+ <entry><literal>swapping relation files</literal></entry>
3755+ <entry>
3756+ The command is currently swapping newly-built files into place.
3757+ </entry>
3758+ </row>
3759+ <row>
3760+ <entry><literal>rebuilding index</literal></entry>
3761+ <entry>
3762+ The command is currently rebuilding an index.
3763+ </entry>
3764+ </row>
3765+ <row>
3766+ <entry><literal>performing final cleanup</literal></entry>
3767+ <entry>
3768+ The command is performing final cleanup. When this phase is
3769+ completed, <command>CLUSTER</command>
3770+ or <command>VACUUM FULL</command> will end.
3771+ </entry>
3772+ </row>
3773+ </tbody>
3774+ </tgroup>
3775+ </table>
3776+
35903777 </sect2>
35913778 </sect1>
35923779
0 commit comments