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 1wIsnb-008Yoy-3C for pgsql-hackers@arkaria.postgresql.org; Fri, 01 May 2026 18:41:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wIsnb-00Bwh2-07 for pgsql-hackers@arkaria.postgresql.org; Fri, 01 May 2026 18:41:15 +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 1wIsna-00Bwgu-20 for pgsql-hackers@lists.postgresql.org; Fri, 01 May 2026 18:41:14 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wIsnY-00000003jeN-2H8Z for pgsql-hackers@lists.postgresql.org; Fri, 01 May 2026 18:41:13 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-82f4a53ae20so1559133b3a.3 for ; Fri, 01 May 2026 11:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777660872; cv=none; d=google.com; s=arc-20240605; b=baIsC6zprq9VeFShlgZ8jvd0x8poXvYrasx5a+MgjbQZfkeETqMtpqI8wWx2BQCGng aeFC0Dvy2fBUooPRgmakRMadfg51/qaqCPFUZj8ju+wfTV3AubMpmEwUcX3EPKz5WBwP MWa8UDKpBZ8/+c1PSq+//SIH23q8eWYhLzrO6h3Y1ICERdl/zWAsqbMBV2CXS6IqxTln 0HGU4Yn2K4OwwerbyDKPd/SLTTY1wQOzQAA7VRkuVZL/ekcWNfWlLfzS3VUOcjc4QhEM Ko7pUk7E2BdRlle4ANVmZoyWulbR908sRG57iBDEB/SPiYLXjs0ohYBgO+QLJE8LRgGY BUPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mbcSB1M6vndXKotFs3QNUM26M56d6ZmJeH5D3WvShEo=; fh=rfsvFaKrH2Ta8gV2/wSkpFmDw50m8DTcmjIn8PGQFbU=; b=dmfqJXN2d5CwYJKMoW0lE9QPEAWLELU4wVCDFvsLxRjbamAkHUgbNlZCRK7YV6FnW0 5gCkxbohDruEPstKXKuoA0I7khnJ/wwAH4SzotTMfMY83nu3t7RE9CejLuDYWRctFmzc pfmb7N72Kx58dkiuJeh7o8/UILdmVA2bMe1qxXob7JlOeE6nqXagYl7UOkT0Rv8wAkGE V/ZJ5Ky/lQe3X70uNVm8xt+tC+wn+DGl0c/KTcq0jhvwmNNgX7Njp4WYM0usUgcFUG0b vR2VCtIxuy06DRBMQY8r+HlyplaoRlSGz+UaCERcjqMcc69C49Ta9cqlNZ7eBPTsksb9 hPww==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777660872; x=1778265672; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mbcSB1M6vndXKotFs3QNUM26M56d6ZmJeH5D3WvShEo=; b=bic3tC856BBK8LxFdQf7fxEfR17WbxVsTA/iGL6deL+N/XOF2HtGJmd2yGxa20z6B+ s+JXc/47d+eDpbmS4iRv4ev/XhZTB8IqqagTGa3tKS3Okqiy+73j60QOsx/8ZpyGmIPz K4/+jJyfIwtQwYqFDSHOnvco4wWE9rbkD/wYX4Y3kNpUI1I7bQcsdaJszR6tUD7bynR+ js9cxN7XMbOOghjqcHPwu3v1gqmL/EZOvDFeVS1ZvzE1E6Zo0+D3Y19UVyPjtggvIJJO HeGoF1QTaoevUjIuB2tjG2+LMBjYCVLQv1T3vZAVBZUKsnUbeUJkz+gD+VNWZOaWli7q nl1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777660872; x=1778265672; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mbcSB1M6vndXKotFs3QNUM26M56d6ZmJeH5D3WvShEo=; b=Msm7LAw8MApBXSvCiMUzHnkR6i4wWHpk1Ahyg4HZhN9uYQjKbyyKK2roZHMq/edaQd UtD1EtaAix0n1h9fZ92oJnsPikImlzn9ukqB2+A3tAsWFD5SO8WHICD3pV7BVVqYTUOB K6wLnXTg3L2Kb8iWk0+tBjxvg1LM4LEUZjdjQKIIyYHyyKIqnyU0vSnPcsIWphPN4DkN ckukf6tS/2DdtUjQ4AxBQ0Kryg3yYU+r51W71Ko8tIs0se7ADuz2pBkyUgsQ6KjHP0jD pakDLiPD8BLMWHYZVPkzbCHPCuNp9ndkyD3SK3a+HRTFWMlPILYsb8WLwnz2aNbbGonJ 4FcA== X-Forwarded-Encrypted: i=1; AFNElJ+OARhBfMJQyBTq9DXWcGk1A+EvjqhgUhqzZ0AGcaSNXzGqan4g1V1IaQS1l/oW+cMTzvpCKL+i0W5kZYvL@lists.postgresql.org X-Gm-Message-State: AOJu0Yyx5r+1G+9CJZJ1oA11VqyjOYK4Sf5lHeYjAft08mfWLljCKEj5 dUN8dTZbtE4jEOV+ml1DDk3PIUpGXnx6UccRsMjC62GxYFuRsoJf6DWhbuL7WUtM6aqdYwsMfkB toy91J9XLesCJb++GhCwCy7X0P0SEPRI= X-Gm-Gg: AeBDiesvEWjYZCyy6jBNxP2p/rdCkrf+8+S1frtgWlOG6kpmws/Wq8cFFaMJTAr8YnZ yX7VbMB9U87RvGUFdLEhrj6VLi4kedjGvVuWjOmv9x7hl1nOFCqqhNuUmoIlBl13QxEyVgf/sXH b52MIKR4NSsee9iJ6kqgVjQeHArEGsGkL2l+FOxAAkqeu2NtqpAUFOXYErrMCEi2sKvMwfzz3zD W9NCfPJI7oZ8QjB94FXlIKCGdBfQMFbnX/V2Vn/rd1l571Ml/8x8l7SXOpYyrsekDuIZgwpkoY3 zPTPzdGcYQiYFnE= X-Received: by 2002:a05:6a00:4fc7:b0:827:3d52:5d1a with SMTP id d2e1a72fcca58-8352cdd625bmr404100b3a.0.1777660871905; Fri, 01 May 2026 11:41:11 -0700 (PDT) MIME-Version: 1.0 References: <38690b0e-f91b-46fa-b72a-57775612e463@postgrespro.ru> <2oh4o4zvj2jreituesxgglmnseo2m2brffms3lvao6mseemto6@32v67ejhxlht> In-Reply-To: From: Masahiko Sawada Date: Fri, 1 May 2026 11:40:33 -0700 X-Gm-Features: AVHnY4JOmUSH0AXZhiYtt_4iiY_nH-3lOVnyCGnfeNVco5aUy6DM843yApA0S0Y Message-ID: Subject: Re: Support logical replication of DDLs, take2 To: Hannu Krosing Cc: Andres Freund , Dilip Kumar , Amit Kapila , Vitaly Davydov , Ashutosh Bapat , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Apr 30, 2026 at 7:03=E2=80=AFAM Hannu Krosing w= rote: > > On Wed, Apr 29, 2026 at 2:10=E2=80=AFPM Andres Freund wrote: > > > > Hi, > > > > On 2026-04-29 10:07:04 +0200, Hannu Krosing wrote: > > > On Wed, Apr 29, 2026 at 5:39=E2=80=AFAM Dilip Kumar wrote: > > > > > > > I am trying to understand your idea. If we are trying to deparse fr= om > > > > an actual system table using a snapshot, why don't we just use the > > > > WAL? I mean, the WAL should contain the actual catalog modification= s > > > > it has made. > > > > > > We have the full data in the catalog and we would likely need catalog > > > queries for any change, even when de-parsing the tree. > > > > > > And we should not add the extra load on the original DDL side, just a= s > > > we don't for DML. > > > > That can't be a relevant cost compared to everything else. > > Probably not. But unless we somehow encode "everything" at that point > we will make building different DDL decoders harder down the line. > > So why not just save the normally serialised parse tree at this point > and let the decoders decide to do whatever they need. > > > > At most we could just serialize the statement tree into the WAL, > > > though even that may be an overkill if we can get the change from > > > existing records. > > > > > > - insert new row in pg_class --> extract the CREATE TABLE (or INDEX, = or ...) > > > - update row in pg_class or insert, update or delete a row in > > > pg_attribute --> extract ALTER TABLE > > > - except when it just updates relfilenod --> extract TRUNCATE > > > - delete row in pg_class --> DROP TABLE > > > - dml on pg_constraint --> ALTER TABLE > > > > > > ... etc > > > > That doesn't work in the general case, think of > > ALTER TABLE ... ALTER COLUMN ... TYPE foo USING (...) > > > > There's a big difference between USING(foo::int8) and USING (pg_size_by= tes(foo)) > > but it's nowhere visible in the WAL. > > It can't be a big difference if it is not visible in the WAL. If we send the rewritten tuples made during ALTER TABLE execution via logical replication, there would not be a big difference. However, if we send only the re-constructed ALTER TABLE statement, there is. I think that replicating ALTER TABLE should behave the latter because we might not need table rewrites in more ALTER TABLE cases in newer PostgreSQL versions. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com