Skip to content

Commit 5ddfebd

Browse files
committed
Reduce relcache access in WAL sender streaming logical changes
get_rel_sync_entry(), which is called each time a change needs to be logically replicated, is a rather hot code path in the WAL sender sending logical changes. This code path was doing a relcache access on relkind and relpartition for each logical change, but we only need to know this information when building or re-building the cached information for a relation. Some measurements prove that this is noticeable in perf profiles, particularly when attempting to replicate changes from relations that are not published as these cause less overhead in the WAL sender, delaying further the replication of changes for relations that are published. Issue introduced in 83fd453. Author: Hou Zhijie Reviewed-by: Kyotaro Horiguchi, Euler Taveira Discussion: https://postgr.es/m/OS0PR01MB5716E863AA9E591C1F010F7A947D9@OS0PR01MB5716.jpnprd01.prod.outlook.com Backpatch-through: 13
1 parent f9db153 commit 5ddfebd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/replication/pgoutput/pgoutput.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,6 @@ static RelationSyncEntry *
10081008
get_rel_sync_entry(PGOutputData *data, Oid relid)
10091009
{
10101010
RelationSyncEntry *entry;
1011-
bool am_partition = get_rel_relispartition(relid);
1012-
char relkind = get_rel_relkind(relid);
10131011
bool found;
10141012
MemoryContext oldctx;
10151013

@@ -1041,6 +1039,8 @@ get_rel_sync_entry(PGOutputData *data, Oid relid)
10411039
List *pubids = GetRelationPublications(relid);
10421040
ListCell *lc;
10431041
Oid publish_as_relid = relid;
1042+
bool am_partition = get_rel_relispartition(relid);
1043+
char relkind = get_rel_relkind(relid);
10441044

10451045
/* Reload publications if needed before use. */
10461046
if (!publications_valid)

0 commit comments

Comments
 (0)