Commit ef75140f authored by Amit Kapila's avatar Amit Kapila

Avoid calls to RelationGetRelationName() and RelationGetNamespace() in

vacuum code.

After commit b61d161c, during vacuum, we cache the information of
relation name and relation namespace in local structure LVRelStats so that
we can use it in an error callback function.  We can use the cached
information to avoid the calls to RelationGetRelationName(),
RelationGetNamespace() and get_namespace_name().  This is mainly for the
consistent in vacuum code path but it will avoid the extra syscache lookup
we do in get_namespace_name().

Author: Justin Pryzby
Reviewed-by: Amit Kapila
Discussion: https://www.postgresql.org/message-id/20191120210600.GC30362@telsasoft.com
parent f01157e2
...@@ -636,8 +636,8 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, ...@@ -636,8 +636,8 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params,
} }
appendStringInfo(&buf, msgfmt, appendStringInfo(&buf, msgfmt,
get_database_name(MyDatabaseId), get_database_name(MyDatabaseId),
get_namespace_name(RelationGetNamespace(onerel)), vacrelstats->relnamespace,
RelationGetRelationName(onerel), vacrelstats->relname,
vacrelstats->num_index_scans); vacrelstats->num_index_scans);
appendStringInfo(&buf, _("pages: %u removed, %u remain, %u skipped due to pins, %u skipped frozen\n"), appendStringInfo(&buf, _("pages: %u removed, %u remain, %u skipped due to pins, %u skipped frozen\n"),
vacrelstats->pages_removed, vacrelstats->pages_removed,
...@@ -808,7 +808,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, ...@@ -808,7 +808,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
if (params->nworkers > 0) if (params->nworkers > 0)
ereport(WARNING, ereport(WARNING,
(errmsg("disabling parallel option of vacuum on \"%s\" --- cannot vacuum temporary tables in parallel", (errmsg("disabling parallel option of vacuum on \"%s\" --- cannot vacuum temporary tables in parallel",
RelationGetRelationName(onerel)))); vacrelstats->relname)));
} }
else else
lps = begin_parallel_vacuum(RelationGetRelid(onerel), Irel, lps = begin_parallel_vacuum(RelationGetRelid(onerel), Irel,
...@@ -1693,7 +1693,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, ...@@ -1693,7 +1693,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
if (vacuumed_pages) if (vacuumed_pages)
ereport(elevel, ereport(elevel,
(errmsg("\"%s\": removed %.0f row versions in %u pages", (errmsg("\"%s\": removed %.0f row versions in %u pages",
RelationGetRelationName(onerel), vacrelstats->relname,
tups_vacuumed, vacuumed_pages))); tups_vacuumed, vacuumed_pages)));
/* /*
...@@ -1722,7 +1722,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, ...@@ -1722,7 +1722,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
ereport(elevel, ereport(elevel,
(errmsg("\"%s\": found %.0f removable, %.0f nonremovable row versions in %u out of %u pages", (errmsg("\"%s\": found %.0f removable, %.0f nonremovable row versions in %u out of %u pages",
RelationGetRelationName(onerel), vacrelstats->relname,
tups_vacuumed, num_tuples, tups_vacuumed, num_tuples,
vacrelstats->scanned_pages, nblocks), vacrelstats->scanned_pages, nblocks),
errdetail_internal("%s", buf.data))); errdetail_internal("%s", buf.data)));
...@@ -1854,7 +1854,7 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats) ...@@ -1854,7 +1854,7 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
ereport(elevel, ereport(elevel,
(errmsg("\"%s\": removed %d row versions in %d pages", (errmsg("\"%s\": removed %d row versions in %d pages",
RelationGetRelationName(onerel), vacrelstats->relname,
tupindex, npages), tupindex, npages),
errdetail_internal("%s", pg_rusage_show(&ru0)))); errdetail_internal("%s", pg_rusage_show(&ru0))));
...@@ -2402,7 +2402,7 @@ lazy_vacuum_index(Relation indrel, IndexBulkDeleteResult **stats, ...@@ -2402,7 +2402,7 @@ lazy_vacuum_index(Relation indrel, IndexBulkDeleteResult **stats,
ereport(elevel, ereport(elevel,
(errmsg(msg, (errmsg(msg,
RelationGetRelationName(indrel), vacrelstats->indname,
dead_tuples->num_tuples), dead_tuples->num_tuples),
errdetail_internal("%s", pg_rusage_show(&ru0)))); errdetail_internal("%s", pg_rusage_show(&ru0))));
...@@ -2565,7 +2565,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) ...@@ -2565,7 +2565,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
vacrelstats->lock_waiter_detected = true; vacrelstats->lock_waiter_detected = true;
ereport(elevel, ereport(elevel,
(errmsg("\"%s\": stopping truncate due to conflicting lock request", (errmsg("\"%s\": stopping truncate due to conflicting lock request",
RelationGetRelationName(onerel)))); vacrelstats->relname)));
return; return;
} }
...@@ -2631,7 +2631,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) ...@@ -2631,7 +2631,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
ereport(elevel, ereport(elevel,
(errmsg("\"%s\": truncated %u to %u pages", (errmsg("\"%s\": truncated %u to %u pages",
RelationGetRelationName(onerel), vacrelstats->relname,
old_rel_pages, new_rel_pages), old_rel_pages, new_rel_pages),
errdetail_internal("%s", errdetail_internal("%s",
pg_rusage_show(&ru0)))); pg_rusage_show(&ru0))));
...@@ -2696,7 +2696,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats) ...@@ -2696,7 +2696,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
{ {
ereport(elevel, ereport(elevel,
(errmsg("\"%s\": suspending truncate due to conflicting lock request", (errmsg("\"%s\": suspending truncate due to conflicting lock request",
RelationGetRelationName(onerel)))); vacrelstats->relname)));
vacrelstats->lock_waiter_detected = true; vacrelstats->lock_waiter_detected = true;
return blkno; return blkno;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment