Re: [HACKERS] CLUSTER command progress monitor
Tatsuro Yamada <yamada.tatsuro@lab.ntt.co.jp>
From: Tatsuro Yamada <yamada.tatsuro@lab.ntt.co.jp>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>,
Dmitry Dolgov <9erthalion6@gmail.com>, Peter Geoghegan <pg@bowt.ie>,
PostgreSQL-development <pgsql-hackers@postgresql.org>,
Jeff Janes <jeff.janes@gmail.com>,
Thomas Munro <thomas.munro@enterprisedb.com>,
Michael Paquier <michael.paquier@gmail.com>
Date: 2019-03-05T08:56:39Z
Lists: pgsql-hackers
Hi Robert!
On 2019/03/05 11:35, Robert Haas wrote:
> On Mon, Mar 4, 2019 at 5:38 AM Tatsuro Yamada
> <yamada.tatsuro@lab.ntt.co.jp> wrote:
>> === Current design ===
>>
>> CLUSTER command uses Index Scan or Seq Scan when scanning the heap.
>> Depending on which one is chosen, the command will proceed in the
>> following sequence of phases:
>>
>> * Scan method: Seq Scan
>> 0. initializing (*2)
>> 1. seq scanning heap (*1)
>> 3. sorting tuples (*2)
>> 4. writing new heap (*1)
>> 5. swapping relation files (*2)
>> 6. rebuilding index (*2)
>> 7. performing final cleanup (*2)
>>
>> * Scan method: Index Scan
>> 0. initializing (*2)
>> 2. index scanning heap (*1)
>> 5. swapping relation files (*2)
>> 6. rebuilding index (*2)
>> 7. performing final cleanup (*2)
>>
>> VACUUM FULL command will proceed in the following sequence of phases:
>>
>> 1. seq scanning heap (*1)
>> 5. swapping relation files (*2)
>> 6. rebuilding index (*2)
>> 7. performing final cleanup (*2)
>>
>> (*1): increasing the value in heap_tuples_scanned column
>> (*2): only shows the phase in the phase column
>
> All of that sounds good.
>
>> The view provides the information of CLUSTER command progress details as follows
>> # \d pg_stat_progress_cluster
>> View "pg_catalog.pg_stat_progress_cluster"
>> Column | Type | Collation | Nullable | Default
>> ---------------------------+---------+-----------+----------+---------
>> pid | integer | | |
>> datid | oid | | |
>> datname | name | | |
>> relid | oid | | |
>> command | text | | |
>> phase | text | | |
>> cluster_index_relid | bigint | | |
>> heap_tuples_scanned | bigint | | |
>> heap_tuples_vacuumed | bigint | | |
>
> Still not sure if we need heap_tuples_vacuumed. We could try to
> report heap_blks_scanned and heap_blks_total like we do for VACUUM, if
> we're using a Seq Scan.
I have no strong opinion to add heap_tuples_vacuumed, so I'll remove that in
next patch.
Regarding heap_blks_scanned and heap_blks_total, I suppose that it is able to
get those from initscan(). I'll investigate it more.
cluster.c
copy_heap_data()
heap_beginscan()
heap_beginscan_internal()
initscan()
>> === Discussion points ===
>>
>> - Progress counter for "3. sorting tuples" phase
>> - Should we add pgstat_progress_update_param() in tuplesort.c like a
>> "trace_sort"?
>> Thanks to Peter Geoghegan for the useful advice!
>
> How would we avoid an abstraction violation?
Hmm... What do you mean an abstraction violation?
If it is difficult to solve, I'd not like to add the progress counter for the sorting tuples.
>> - Progress counter for "6. rebuilding index" phase
>> - Should we add "index_vacuum_count" in the view like a vacuum progress monitor?
>> If yes, I'll add pgstat_progress_update_param() to reindex_relation() of index.c.
>> However, I'm not sure whether it is okay or not.
>
> Doesn't seem unreasonable to me.
I see, I'll add it later.
Regards,
Tatsuro Yamada
Commits
-
Fix progress reporting of CLUSTER / VACUUM FULL
- 6212276e4343 13.0 landed
- da47e43dc32e 12.0 landed
-
Fix thinko when ending progress report for a backend
- f4b91a50e9e6 9.6.16 landed
- 4950f09e7ae2 10.11 landed
- af28744288b1 11.6 landed
- 4c3e750ab4b5 12.0 landed
- ae060a52b288 13.0 landed
-
Report progress of REINDEX operations
- 03f9e5cba0ee 12.0 cited
-
Add progress reporting for CLUSTER and VACUUM FULL.
- 6f97457e0ddd 12.0 landed
-
Un-hide most cascaded-drop details in regression test results.
- 940311e4bb32 12.0 cited
-
Fix memory leak in printtup.c.
- f2004f19ed9c 12.0 cited
-
Remove unused macro
- fb5806533f9f 12.0 cited