Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vUxr7-00AE1H-1z for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 01:58:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vUxr4-00F2zD-0t for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 01:58:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vUxr3-00F2z5-38 for pgsql-hackers@lists.postgresql.org; Mon, 15 Dec 2025 01:58:30 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vUxr2-000mPb-04 for pgsql-hackers@lists.postgresql.org; Mon, 15 Dec 2025 01:58:30 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2a0f3f74587so5199625ad.2 for ; Sun, 14 Dec 2025 17:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765763906; x=1766368706; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Z4Gyt23jR9cktwNCqvu8/fp70C1hjoxZH+Chjq7SfDY=; b=gmS6IgX7gaQzOIo5ZBdJkZn9l/CX+Lh0Z9CCcsqvNLsa5frPC9mH9jS1KEaUoLsulC 2y+2zJNEMKQTMZfPbkIqsUJ/6E9ekvOOz0qaYw5p+kcacV242ngkS/t9aQj1U+WDyOI6 3Mys2g8a+V/G7XTMVOTgVqQMmQN7bWGTDfDuEM7girODg3xLjI+ax4JtjqNwte5rRaJ/ q5TRGXnwpxE3YBOK3/QYkjk8R8CgNpPlkSZYR8ukL3aVk8Lv4OOkWGDqeBi3ZbvuftIM PSalJvir30Krp+9tA/x/lFUeIUfa7RpSMQyrkLhGrWFw4wfivEQ7aBO+Og/ZxuHKTW2x D7ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765763906; x=1766368706; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Z4Gyt23jR9cktwNCqvu8/fp70C1hjoxZH+Chjq7SfDY=; b=heeAITKvpu7uRSs+5z+tmrLqnsYrUv7ZEsmqbms5o/q4bnm7MSn7jT6bqqF2jTGxzk iiBne7FYK9nIxVhckG5GhkJqGbTWsNzbBzCKcxDzAwpvx9ULMpVgnhyiEib+Qh1fAQ1Y ATTCe7MKdVdLVAK00MBGWxoEybAl4u8fA4o5HqhrqZvg2+Dxb+v1Gd74umbL/jWa0oFz N5tNPnIpvv2mh+cgkSoMBtFHTceyMcvqdAgNOjoNKty+sMGCG3kPaHncyX+RUAUTIlxJ 1+e0NJfBR7qqr/SFweX7bKiaLYyaZ3LfyRtfC8gS4WAY/0xSfGKwi+F/TLxamg3ze8HQ uxHw== X-Gm-Message-State: AOJu0YwjYvR8IUwJhIN4Y6GRCjTZG/7VdLfl+9Os+wS3ICO2cHz5CFlY O/68hqvtTaF2xPTpuxKvmpgEX+ZPFejsloku0dqkiz4R2lIvt4cMxg3p X-Gm-Gg: AY/fxX5xWGEexFOpS5qgoa+zGQUN71ntojg7YQ4OD4jeBqXFfxahXF7DF9E0MPAiOV1 t+YWh9azlbpk4x8533py2hOIQUsxyKth7CTVS39MgU5MnOWhA5qZWmkoRKCi2dVDjlu6GhI02rn WdF5X5b43HNjbi668HCVWgdMwbO0BqV22k7Ju9U5EN1HF/NQepZ6Z/M3qnV4X1mcxAINlos01wq 7s7e3hGnR4Dsgvn8JRHNfAyrSkvurs6hAlLoZjxBiwdH3Yo8H2wkkY1XuKJNqGlqcZrhLCwCczQ pb4dYEON26AJphAWBoZq00FSs1b5U/b7FUd9L/01hNb2ci+s7psNBQjs+syXzxdEJiSChELbEUu TT106eeUWbkiTyQxZApQAyXXRkIQE88ncrY2x61f+O26nQ63LpwyZNqgq7kLjlMRU/E5FQggjTD lajFnGhdGczqsv+qHWpm4= X-Google-Smtp-Source: AGHT+IGybQSBgFC6YyWS/XjGdvlhZof4A+rlCBAESiqUvYlvKhHJY/j+2lgt1JbNCdFGmtFonGwueQ== X-Received: by 2002:a17:903:1b45:b0:27e:dc53:d239 with SMTP id d9443c01a7336-29f26eb2a1cmr83984685ad.35.1765763905636; Sun, 14 Dec 2025 17:58:25 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29eea06b651sm116000365ad.94.2025.12.14.17.58.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Dec 2025 17:58:25 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: Improve logical replication usability when tables lack primary keys From: Chao Li In-Reply-To: Date: Mon, 15 Dec 2025 09:57:49 +0800 Cc: Postgres hackers , Amit Kapila Content-Transfer-Encoding: quoted-printable Message-Id: <7BC72FB9-2235-414F-9D45-EA2C8A2FF09A@gmail.com> References: To: Euler Taveira X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Nov 11, 2025, at 20:09, Euler Taveira wrote: >=20 > On Mon, Nov 10, 2025, at 5:06 AM, Chao Li wrote: >> I evaluated a few approaches and am proposing the following: >>=20 >> - Introduce a new GUC: = `logical_replication_fallback_to_full_identity`. >> - When enabled, if a table being logically replicated has no primary=20= >> key, the system automatically uses `REPLICATION IDENTITY FULL` for = that=20 >> table. >> - This setting can be applied at the database level, so large systems=20= >> do not need to enable it cluster-wide unless desired. >> - When the WAL sender transmits relation metadata, if fallback has=20 >> occurred, it explicitly reports `FULL` as the replication identity to=20= >> the subscriber, so there is limited impact on the subscriber. >>=20 >=20 > If I understand your proposal correctly, you want to add a new = fallback to > replica identity. We already have a fallback for DEFAULT that means no = primary > key is the same as NOTHING. I didn't like your proposal. It is too = restrictive. >=20 > However, I see some usefulness in introducing a GUC = default_replica_identity. > The proposal is similar to access method = (default_table_access_method). The > DEFAULT option selects the replica identity sets as = default_replica_identity > parameter. You need to add a new option (PRIMARY KEY); that should be = the > default value. (If we don't want to break the backward compatibility, = this new > option should fallback to NOTHING if there is no primary key. Another > alternative is to have a strict and non-strict option. I prefer the = former.) Of > course, the USING INDEX option cannot be used. For pg_dump, you need = to use SET > command to inform the default_replica_identity value so tables with = the same > option as default_replica_identity doesn't emit an ALTER TABLE = command. >=20 I=E2=80=99ve thought this over and discussed it with our field teams. It = looks to us that introducing a new GUC like default_replica_identity = does not really address our pain point. Our core requirement is to allow tables without a primary key to use = FULL as the replica identity, while tables with a primary key should = continue to use DEFAULT. If we add default_replica_identity and set it to FULL, then a newly = created table that does have a primary key would also end up using FULL, = which is definitely not what we want. As you mentioned, PostgreSQL already has a fallback from DEFAULT to = NOTHING. What we actually want is the ability to customize this = fallback, so that users can choose whether DEFAULT falls back to NOTHING = or to FULL. Customizing the fallback via a new GUC would also allow = field teams to set this option per database. If we do want to add default_replica_identity, I think that should be = treated as a separate topic. By the way, could you explain what use case = you have in mind for it? Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/