diff options
| author | Peter Geoghegan | 2022-04-15 21:20:56 +0000 |
|---|---|---|
| committer | Peter Geoghegan | 2022-04-15 21:20:56 +0000 |
| commit | bdb71dbe80d0560f84255e05b73f449e11007325 (patch) | |
| tree | b38e9b815247e48ac2129a0e5511c57994c475bf | |
| parent | 357c8455e64915f2d8f50ca5853eb91b74470d96 (diff) | |
VACUUM VERBOSE: Show dead items for an empty table.
Be consistent about the lines that VACUUM VERBOSE outputs by including
an "index scan not needed: " line for completely empty tables. This
makes the output more readable, especially with multiple distinct VACUUM
operations processed by the same VACUUM command. It's also more
consistent; even empty tables can use the failsafe, which wasn't
reported in the standard way until now.
Follow-up to commit 6e20f460, which taught VACUUM VERBOSE to be more
consistent about reporting on scanned pages with empty tables.
| -rw-r--r-- | src/backend/access/heap/vacuumlazy.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 3259ebd98a4..8abb6dca419 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -715,31 +715,29 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"), vacrel->NewRelminMxid, diff); } - if (orig_rel_pages > 0) + if (vacrel->do_index_vacuuming) { - if (vacrel->do_index_vacuuming) - { - if (vacrel->nindexes == 0 || vacrel->num_index_scans == 0) - appendStringInfoString(&buf, _("index scan not needed: ")); - else - appendStringInfoString(&buf, _("index scan needed: ")); + if (vacrel->nindexes == 0 || vacrel->num_index_scans == 0) + appendStringInfoString(&buf, _("index scan not needed: ")); + else + appendStringInfoString(&buf, _("index scan needed: ")); - msgfmt = _("%u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n"); - } + msgfmt = _("%u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n"); + } + else + { + if (!vacrel->failsafe_active) + appendStringInfoString(&buf, _("index scan bypassed: ")); else - { - if (!vacrel->failsafe_active) - appendStringInfoString(&buf, _("index scan bypassed: ")); - else - appendStringInfoString(&buf, _("index scan bypassed by failsafe: ")); + appendStringInfoString(&buf, _("index scan bypassed by failsafe: ")); - msgfmt = _("%u pages from table (%.2f%% of total) have %lld dead item identifiers\n"); - } - appendStringInfo(&buf, msgfmt, - vacrel->lpdead_item_pages, - 100.0 * vacrel->lpdead_item_pages / orig_rel_pages, - (long long) vacrel->lpdead_items); + msgfmt = _("%u pages from table (%.2f%% of total) have %lld dead item identifiers\n"); } + appendStringInfo(&buf, msgfmt, + vacrel->lpdead_item_pages, + orig_rel_pages == 0 ? 100.0 : + 100.0 * vacrel->lpdead_item_pages / orig_rel_pages, + (long long) vacrel->lpdead_items); for (int i = 0; i < vacrel->nindexes; i++) { IndexBulkDeleteResult *istat = vacrel->indstats[i]; |
