Skip to content

Commit bdb71db

Browse files
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 6e20f46, which taught VACUUM VERBOSE to be more consistent about reporting on scanned pages with empty tables.
1 parent 357c845 commit bdb71db

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/backend/access/heap/vacuumlazy.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -715,31 +715,29 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
715715
_("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
716716
vacrel->NewRelminMxid, diff);
717717
}
718-
if (orig_rel_pages > 0)
718+
if (vacrel->do_index_vacuuming)
719719
{
720-
if (vacrel->do_index_vacuuming)
721-
{
722-
if (vacrel->nindexes == 0 || vacrel->num_index_scans == 0)
723-
appendStringInfoString(&buf, _("index scan not needed: "));
724-
else
725-
appendStringInfoString(&buf, _("index scan needed: "));
720+
if (vacrel->nindexes == 0 || vacrel->num_index_scans == 0)
721+
appendStringInfoString(&buf, _("index scan not needed: "));
722+
else
723+
appendStringInfoString(&buf, _("index scan needed: "));
726724

727-
msgfmt = _("%u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n");
728-
}
725+
msgfmt = _("%u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n");
726+
}
727+
else
728+
{
729+
if (!vacrel->failsafe_active)
730+
appendStringInfoString(&buf, _("index scan bypassed: "));
729731
else
730-
{
731-
if (!vacrel->failsafe_active)
732-
appendStringInfoString(&buf, _("index scan bypassed: "));
733-
else
734-
appendStringInfoString(&buf, _("index scan bypassed by failsafe: "));
732+
appendStringInfoString(&buf, _("index scan bypassed by failsafe: "));
735733

736-
msgfmt = _("%u pages from table (%.2f%% of total) have %lld dead item identifiers\n");
737-
}
738-
appendStringInfo(&buf, msgfmt,
739-
vacrel->lpdead_item_pages,
740-
100.0 * vacrel->lpdead_item_pages / orig_rel_pages,
741-
(long long) vacrel->lpdead_items);
734+
msgfmt = _("%u pages from table (%.2f%% of total) have %lld dead item identifiers\n");
742735
}
736+
appendStringInfo(&buf, msgfmt,
737+
vacrel->lpdead_item_pages,
738+
orig_rel_pages == 0 ? 100.0 :
739+
100.0 * vacrel->lpdead_item_pages / orig_rel_pages,
740+
(long long) vacrel->lpdead_items);
743741
for (int i = 0; i < vacrel->nindexes; i++)
744742
{
745743
IndexBulkDeleteResult *istat = vacrel->indstats[i];

0 commit comments

Comments
 (0)