pgsql: Use direct hash lookup in logicalrep_partmap_invalidate_cb()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use direct hash lookup in logicalrep_partmap_invalidate_cb()
Date: 2026-07-27 00:53:11
Message-ID: E1wo9ah-00000000S6D-0eC8@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use direct hash lookup in logicalrep_partmap_invalidate_cb()

This replaces an O(N) hash_seq_search() loop by an O(1) lookup, removing
a TODO item, making the invalidation callback faster when dealing with
many relations. This can work because LogicalRepPartMap is keyed by a
partition OID, and a relmapentry's localreloid matches with it.

An assertion is added in logicalrep_partition_open() to enforce the fact
that localreloid matches with the hash key.

Author: DaeMyung Kang <charsyam(at)gmail(dot)com>
Discussion: https://postgr.es/m/20260417174450.4158878-1-charsyam@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0962f9e344390c69e44bc55675510b2fa2b3f778

Modified Files
--------------
src/backend/replication/logical/relation.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-07-27 00:59:16 pgsql: Update .gitignore in test/modules/nbtree
Previous Message Peter Geoghegan 2026-07-26 16:50:55 pgsql: Add _bt_set_startikey row compare test coverage.