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 1vJ0V5-006QrI-12 for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Nov 2025 02:22:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vJ0V2-008qqP-26 for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Nov 2025 02:22:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vJ0V2-008qqF-10 for pgsql-hackers@lists.postgresql.org; Wed, 12 Nov 2025 02:22:20 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vJ0Uz-006e2D-2E for pgsql-hackers@lists.postgresql.org; Wed, 12 Nov 2025 02:22:19 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2956d816c10so3453175ad.1 for ; Tue, 11 Nov 2025 18:22:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762914136; x=1763518936; 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=arQsjKE7imYRwSlXbTEIg/tqL/syzo9wXay1onPclH0=; b=IU/lDKJs5+n3AWrBLifoIhvWCZtjCz/Zj0XLRrFMK7J0ZjtKVwCj0Yh6y1Tf7Edsb4 FLR3G0xHTuqpao060n7G2TxLO3wXX5w4w+Kt+GLTewOR+8yugj80YIlVfs/TWKDdYh/O m9IzJa/FAi/mqrw492FFERRp5yK/IZNdbUcJ9IriMyN3oknSqEVBKZytFQWl1T/a5j84 pZSnBVqA7w5fTgrosEjeIX+uIKtt72dL3BmX7O/yMc66GBDoGPlDVVvsH07NBQUv2w+/ HBdULW98vB1cGUebkg2KeZKeZtjlIXMX9W990185eIYRP5jyhsHAdVsCIASBBkl36m8Z OLPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762914136; x=1763518936; 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=arQsjKE7imYRwSlXbTEIg/tqL/syzo9wXay1onPclH0=; b=VS96oTca3EuTE4X7BJRPRU0uU/LJEH+6YT/Cpa77CLUgzZWk6VAN0rWsBW96XcyW5+ ApL4r6mmqvRJ/r9jL3Lo5f38tI43W+7KVYVgFByscrmXIU1GxYX5eQde4oLjEcfuTOcX DEKz5rD9H/5eqBxMcXKbsgqw/H3dAMQ0xHOKe9p9ByndkqgXrg0Rh4aHfwDmo+M9q4wG b2pt1Er11sBOUrCR8ViUOw3ghTR/qziZA3PxuqSUlLcvRURN6tYwkqMewlYNP1iZ6osS +6SJzEhrpRioPjFY8VgdsSiem/XbkjE0Qj9Uc8U8PCfTD2hUf9QKrDMvC65dAE8S+QMK jnmQ== X-Gm-Message-State: AOJu0Yzy4ha5Y/QhK2hzt6DT17azXukkh2pIkXs6NP4MNgfdk8c7GG2r rGLMCAn8cjvs5o8Sh3d4ZKsP8ws4yzuyJr9hpCxUoASibr3hVgSAxmKU X-Gm-Gg: ASbGncuVYa7prBQu/biHIP4mG2DQ+f7iBL60YTLqSq7CLDJ/pyM9Xa5ng1qedBIA6b+ c5NqWPLlCQErBYrR1yNbs3B0vBKDQCDg6yfV/FddILGwSVHq9+a3w7U0Gi2Xm/fLdhcvaOPSp5C 7Cpq2z234mJtf1UC894GQ2dQ6c/puRvdOnGuMSFTum1nHrPyi1j0wp6JHk9J8uZO4LDEiNpk4dq S/tjtkK/qXSnB7V4I2IVbT0nNjsyhJdcletStN3ZtXPWBRVkT5Mq5ZGtCAxFqQKAjTVlhMkNrif wxZlpkPaPP7vv6scFpK+/ObApCUu6gsw6htt1UDJAJD6CwmJPhZB5MDvSCkXWjyBEjCpZgcJq90 D8tqP4q9/xaisO+wtUcJ5TnnzP7YxbQmL4RtSxZgmCci3yz+3kVBUmJqIvVlz95f2kp9Kq0djGA EaUfHKK2aP5A== X-Google-Smtp-Source: AGHT+IEgicim9KQUjiClsHHp9Xm46TdCblFYHvB4Mwp2TB9E4s7kzeuNnrnqEnWBVJlrXAsQm+YVrQ== X-Received: by 2002:a17:902:e84f:b0:295:19e:487b with SMTP id d9443c01a7336-2984ed7a164mr18222195ad.5.1762914136251; Tue, 11 Nov 2025 18:22:16 -0800 (PST) Received: from smtpclient.apple ([142.171.105.12]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2984dceb2efsm11416545ad.110.2025.11.11.18.22.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Nov 2025 18:22:15 -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: Wed, 12 Nov 2025 10:21:40 +0800 Cc: Postgres hackers Content-Transfer-Encoding: quoted-printable Message-Id: <6F18CF89-F8F1-49DE-A85A-6ED2723FBE76@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 Hi Euler, Thank you very much for the valuable feedback. These are a lot of useful = information. As I mentioned in my first email, my proposal was just an = initial implementation, I am open for discussion from the design = perspective. Actually I explored the solution of adding a GUC for = default_replication_identify. Let me briefly list solutions I explored: 1. The first solution I explored was adding a GUC for = replication_identify_fallback_method, possible options are =E2=80=9Cnothin= g=E2=80=9D and =E2=80=9Cfull=E2=80=9D. I gave up that because the = solution is also an equivalent to the one I proposed of a bool option = (false->nothing, true->full) and a bool option is easier to use. 2. Then I considered to add a GUC for default replication identity which = is the same as you suggested. I gave up that because this solution would = require to update all existing tables=E2=80=99 replication identities. 3. I also considered to add a new replication identity, I hadn't named = it, but meaning was using primary key and fallback to full. I gave up = that because it=E2=80=99s too much complicated than other solutions, and = that would also required to update all existing tables=E2=80=99 = replication identities. 4. Finally I decided the one I proposed. The main reason I chose it is = because 1) production deployments wouldn't need to update existing = table=E2=80=99s replication identity; 2) the change only needs to be = applied in the wal-sender side; 3) without turning on the GUC option, no = any impact. Given there is a similar GUC option default_table_access_method (I = wasn=E2=80=99t aware of that), I think 2 as you suggested might be the = direction to go along with. Let=E2=80=99s wait a few more days to see if other folks may comment as = well. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/