Skip to content

Commit f1affb6

Browse files
Reintroduce dead tuple counter in pg_stat_progress_vacuum.
Commit 667e65a changed both num_dead_tuples and max_dead_tuples columns to dead_tuple_bytes and max_dead_tuple_bytes columns, respectively. But as per discussion, the number of dead tuples collected still provides meaningful insights for users. This commit reintroduces the column for the count of dead tuples, renamed as num_dead_item_ids. It avoids confusion with the number of dead tuples removed by VACUUM, which includes dead heap-only tuples but excludes any pre-existing LP_DEAD items left behind by opportunistic pruning. Bump catalog version. Reviewed-by: Peter Geoghegan, Álvaro Herrera, Andrey Borodin Discussion: https://postgr.es/m/CAD21AoBL5sJE9TRWPyv%2Bw7k5Ee5QAJqDJEDJBUdAaCzGWAdvZw%40mail.gmail.com
1 parent 56a8296 commit f1affb6

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

doc/src/sgml/monitoring.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6268,6 +6268,15 @@ FROM pg_stat_get_backend_idset() AS backendid;
62686268
</para></entry>
62696269
</row>
62706270

6271+
<row>
6272+
<entry role="catalog_table_entry"><para role="column_definition">
6273+
<structfield>num_dead_item_ids</structfield> <type>bigint</type>
6274+
</para>
6275+
<para>
6276+
Number of dead item identifiers collected since the last index vacuum cycle.
6277+
</para></entry>
6278+
</row>
6279+
62716280
<row>
62726281
<entry role="catalog_table_entry"><para role="column_definition">
62736282
<structfield>indexes_total</structfield> <type>bigint</type>

src/backend/access/heap/vacuumlazy.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,13 +2883,19 @@ dead_items_add(LVRelState *vacrel, BlockNumber blkno, OffsetNumber *offsets,
28832883
int num_offsets)
28842884
{
28852885
TidStore *dead_items = vacrel->dead_items;
2886+
const int prog_index[2] = {
2887+
PROGRESS_VACUUM_NUM_DEAD_ITEM_IDS,
2888+
PROGRESS_VACUUM_DEAD_TUPLE_BYTES
2889+
};
2890+
int64 prog_val[2];
28862891

28872892
TidStoreSetBlockOffsets(dead_items, blkno, offsets, num_offsets);
28882893
vacrel->dead_items_info->num_items += num_offsets;
28892894

2890-
/* update the memory usage report */
2891-
pgstat_progress_update_param(PROGRESS_VACUUM_DEAD_TUPLE_BYTES,
2892-
TidStoreMemoryUsage(dead_items));
2895+
/* update the progress information */
2896+
prog_val[0] = vacrel->dead_items_info->num_items;
2897+
prog_val[1] = TidStoreMemoryUsage(dead_items);
2898+
pgstat_progress_update_multi_param(2, prog_index, prog_val);
28932899
}
28942900

28952901
/*

src/backend/catalog/system_views.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,8 @@ CREATE VIEW pg_stat_progress_vacuum AS
12211221
S.param2 AS heap_blks_total, S.param3 AS heap_blks_scanned,
12221222
S.param4 AS heap_blks_vacuumed, S.param5 AS index_vacuum_count,
12231223
S.param6 AS max_dead_tuple_bytes, S.param7 AS dead_tuple_bytes,
1224-
S.param8 AS indexes_total, S.param9 AS indexes_processed
1224+
S.param8 AS num_dead_item_ids, S.param9 AS indexes_total,
1225+
S.param10 AS indexes_processed
12251226
FROM pg_stat_get_progress_info('VACUUM') AS S
12261227
LEFT JOIN pg_database D ON S.datid = D.oid;
12271228

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/* yyyymmddN */
60-
#define CATALOG_VERSION_NO 202405161
60+
#define CATALOG_VERSION_NO 202406141
6161

6262
#endif

src/include/commands/progress.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
#define PROGRESS_VACUUM_NUM_INDEX_VACUUMS 4
2626
#define PROGRESS_VACUUM_MAX_DEAD_TUPLE_BYTES 5
2727
#define PROGRESS_VACUUM_DEAD_TUPLE_BYTES 6
28-
#define PROGRESS_VACUUM_INDEXES_TOTAL 7
29-
#define PROGRESS_VACUUM_INDEXES_PROCESSED 8
28+
#define PROGRESS_VACUUM_NUM_DEAD_ITEM_IDS 7
29+
#define PROGRESS_VACUUM_INDEXES_TOTAL 8
30+
#define PROGRESS_VACUUM_INDEXES_PROCESSED 9
3031

3132
/* Phases of vacuum (as advertised via PROGRESS_VACUUM_PHASE) */
3233
#define PROGRESS_VACUUM_PHASE_SCAN_HEAP 1

src/test/regress/expected/rules.out

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,8 +2052,9 @@ pg_stat_progress_vacuum| SELECT s.pid,
20522052
s.param5 AS index_vacuum_count,
20532053
s.param6 AS max_dead_tuple_bytes,
20542054
s.param7 AS dead_tuple_bytes,
2055-
s.param8 AS indexes_total,
2056-
s.param9 AS indexes_processed
2055+
s.param8 AS num_dead_item_ids,
2056+
s.param9 AS indexes_total,
2057+
s.param10 AS indexes_processed
20572058
FROM (pg_stat_get_progress_info('VACUUM'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
20582059
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
20592060
pg_stat_recovery_prefetch| SELECT stats_reset,

0 commit comments

Comments
 (0)