Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ef75140

Browse files
author
Amit Kapila
committed
Avoid calls to RelationGetRelationName() and RelationGetNamespace() in
vacuum code. After commit b61d161, 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
1 parent f01157e commit ef75140

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/backend/access/heap/vacuumlazy.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params,
636636
}
637637
appendStringInfo(&buf, msgfmt,
638638
get_database_name(MyDatabaseId),
639-
get_namespace_name(RelationGetNamespace(onerel)),
640-
RelationGetRelationName(onerel),
639+
vacrelstats->relnamespace,
640+
vacrelstats->relname,
641641
vacrelstats->num_index_scans);
642642
appendStringInfo(&buf, _("pages: %u removed, %u remain, %u skipped due to pins, %u skipped frozen\n"),
643643
vacrelstats->pages_removed,
@@ -808,7 +808,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
808808
if (params->nworkers > 0)
809809
ereport(WARNING,
810810
(errmsg("disabling parallel option of vacuum on \"%s\" --- cannot vacuum temporary tables in parallel",
811-
RelationGetRelationName(onerel))));
811+
vacrelstats->relname)));
812812
}
813813
else
814814
lps = begin_parallel_vacuum(RelationGetRelid(onerel), Irel,
@@ -1693,7 +1693,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
16931693
if (vacuumed_pages)
16941694
ereport(elevel,
16951695
(errmsg("\"%s\": removed %.0f row versions in %u pages",
1696-
RelationGetRelationName(onerel),
1696+
vacrelstats->relname,
16971697
tups_vacuumed, vacuumed_pages)));
16981698

16991699
/*
@@ -1722,7 +1722,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
17221722

17231723
ereport(elevel,
17241724
(errmsg("\"%s\": found %.0f removable, %.0f nonremovable row versions in %u out of %u pages",
1725-
RelationGetRelationName(onerel),
1725+
vacrelstats->relname,
17261726
tups_vacuumed, num_tuples,
17271727
vacrelstats->scanned_pages, nblocks),
17281728
errdetail_internal("%s", buf.data)));
@@ -1854,7 +1854,7 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
18541854

18551855
ereport(elevel,
18561856
(errmsg("\"%s\": removed %d row versions in %d pages",
1857-
RelationGetRelationName(onerel),
1857+
vacrelstats->relname,
18581858
tupindex, npages),
18591859
errdetail_internal("%s", pg_rusage_show(&ru0))));
18601860

@@ -2402,7 +2402,7 @@ lazy_vacuum_index(Relation indrel, IndexBulkDeleteResult **stats,
24022402

24032403
ereport(elevel,
24042404
(errmsg(msg,
2405-
RelationGetRelationName(indrel),
2405+
vacrelstats->indname,
24062406
dead_tuples->num_tuples),
24072407
errdetail_internal("%s", pg_rusage_show(&ru0))));
24082408

@@ -2565,7 +2565,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
25652565
vacrelstats->lock_waiter_detected = true;
25662566
ereport(elevel,
25672567
(errmsg("\"%s\": stopping truncate due to conflicting lock request",
2568-
RelationGetRelationName(onerel))));
2568+
vacrelstats->relname)));
25692569
return;
25702570
}
25712571

@@ -2631,7 +2631,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
26312631

26322632
ereport(elevel,
26332633
(errmsg("\"%s\": truncated %u to %u pages",
2634-
RelationGetRelationName(onerel),
2634+
vacrelstats->relname,
26352635
old_rel_pages, new_rel_pages),
26362636
errdetail_internal("%s",
26372637
pg_rusage_show(&ru0))));
@@ -2696,7 +2696,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
26962696
{
26972697
ereport(elevel,
26982698
(errmsg("\"%s\": suspending truncate due to conflicting lock request",
2699-
RelationGetRelationName(onerel))));
2699+
vacrelstats->relname)));
27002700

27012701
vacrelstats->lock_waiter_detected = true;
27022702
return blkno;

0 commit comments

Comments
 (0)