pgsql: Use direct hash lookup in logicalrep_partmap_invalidate_cb()

Started by Michael Paquier4 months ago1 messagescommitters
Jump to latest
#1Michael Paquier
michael@paquier.xyz

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@gmail.com>
Discussion: /messages/by-id/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(-)