aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-01-05 10:27:07 +0900
committerMichael Paquier <michael@paquier.xyz>2022-01-05 10:27:07 +0900
commit6ce16088bfed97f982f66a9dc17b8364df289e4d (patch)
tree2d00366cc9d29297c3e81b277e6021408f68befd
parent913a03ec29abcb6c20e5941e5f3ac0578619cd3e (diff)
downloadpostgresql-6ce16088bfed97f982f66a9dc17b8364df289e4d.tar.gz
postgresql-6ce16088bfed97f982f66a9dc17b8364df289e4d.zip
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
-rw-r--r--src/backend/replication/pgoutput/pgoutput.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index 6f6a203dea7..a08da859b44 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -1119,8 +1119,6 @@ static RelationSyncEntry *
get_rel_sync_entry(PGOutputData *data, Oid relid)
{
RelationSyncEntry *entry;
- bool am_partition = get_rel_relispartition(relid);
- char relkind = get_rel_relkind(relid);
bool found;
MemoryContext oldctx;
@@ -1160,6 +1158,8 @@ get_rel_sync_entry(PGOutputData *data, Oid relid)
List *schemaPubids = GetSchemaPublications(schemaId);
ListCell *lc;
Oid publish_as_relid = relid;
+ bool am_partition = get_rel_relispartition(relid);
+ char relkind = get_rel_relkind(relid);
/* Reload publications if needed before use. */
if (!publications_valid)