tablecmds: Open pg_class only when an update is required

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: tablecmds: Open pg_class only when an update is required
Date: 2025-12-11 07:15:30
Message-ID: CAEoWx2k6EKSxpYuh8BJOSDiWqOsyi65C0TSwN0vAutnZ+o617g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

I just noticed that relation_mark_replica_identity() unconditionally opened
pg_class with RowExclusiveLock even in cases where relreplident has no
change, which incurred unnecessary relation opens, lock acquisition.

I just made a tiny refactor that defers opening pg_class until we know that
an update to relreplident is required.

I have manually tested the change, and "make check" passed.

Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
v1-0001-tablecmds-Open-pg_class-only-when-an-update-is-re.patch application/octet-stream 2.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-12-11 07:22:35 Re: Mark function arguments of type "T *" as "const T *" where possible
Previous Message Xueyu Gao 2025-12-11 07:13:40 Re:Re: Propose: Adding a '--enable-failover' option to 'pg_createsubscriber' ver.3