Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3ztO-0006k7-2f for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jul 2021 11:51:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3ztN-0000M5-0s for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jul 2021 11:51:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3ztM-0000Lx-PR for pgsql-hackers@lists.postgresql.org; Thu, 15 Jul 2021 11:51:00 +0000 Received: from mail-yb1-xb2b.google.com ([2607:f8b0:4864:20::b2b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m3ztK-0004nJ-Rr for pgsql-hackers@lists.postgresql.org; Thu, 15 Jul 2021 11:51:00 +0000 Received: by mail-yb1-xb2b.google.com with SMTP id k184so8520557ybf.12 for ; Thu, 15 Jul 2021 04:50:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YFkBVeltn1s+LlZu48R15pfynm5IaSLJfnBRtSnuYR4=; b=CSrsI4Xx9+MA4Ae531tTUQG9HiDL3FFM2dMKEzHwFmI9jrSSwQM0QikVAR0CgdnGUv r2cuQ0m7w1N/6ZhoGz1S51hyybqWfB4EIa1QG9g89xRFr+9wgi650IPjX7JohzK9YRYO YVlLAj4SSjxVlpD8tzX26eGXjWy0bOp4CUaBW2CGFZoyzSn/DqEDDUlfD0a/Q4105OVq jMJHLD3ZmFCbzlHuyYLjPGj6kbTezbc5XHqczcY1K1iESXUqvpzmjvwDqlyugR4TsZc9 h4jnu6KhM3ka9yAUOFFVKSEMUUstOgmlsPxmlTMrghU0FlZoXXAXYSD6WsDo3DdSC+b9 j3Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YFkBVeltn1s+LlZu48R15pfynm5IaSLJfnBRtSnuYR4=; b=H0p/sflDCAvkRs4GsssIrqeiEIjHbbLbVAR8TKtW0x6FejWzPJO+NwTEuHuJB73Qzk r3PnL5iYDc3usMp2ZYd5tB9PB5950s4F5lE8QoUqFAkVtbxdUQEXAGfycmieAouvbs7E 0o+tERiUO4MEjYTio2Q6g1JBJeZTNt7AeVqhxGAD4V3335Az5pcvTikKD9Ic0MOjkZSE KOoCsy9/QHVSWZEzKAE0vbSL6nJujOPvPRMCli5U4Fczqs9l+++FUrk5lyWx1tmolKhB ibCPLe0ijsyKWCZTPF4ICn5IoymvfxHhH5vU++LTRGBmdywG3VHTLaCo18NjgnoTczt7 p6GA== X-Gm-Message-State: AOAM533A7ICqQO4lVxrkENxCVCJXBKs3I5LWaY3YmpsHb0Qdc//W2R9N 71sn0EB3MrsQvvAoLyFfmtktwdrAa1q48RXkp/w= X-Google-Smtp-Source: ABdhPJzdv4WiB1fg+R3LB2IwOC9mBxCJlV1CpdpAC1zGsAjWidc+MCifnLNkuTU+EI5U1oQwa3pq2JcdxZ8l1/zDhE8= X-Received: by 2002:a5b:1cf:: with SMTP id f15mr4607678ybp.89.1626349857467; Thu, 15 Jul 2021 04:50:57 -0700 (PDT) MIME-Version: 1.0 References: <202107132106.wvjgvjgcyezo@alvherre.pgsql> <48e13621-10f7-49ef-bcbe-ed530195efd2@www.fastmail.com> In-Reply-To: From: Greg Nancarrow Date: Thu, 15 Jul 2021 21:50:46 +1000 Message-ID: Subject: Re: row filtering for logical replication To: Amit Kapila Cc: Tomas Vondra , Euler Taveira , Alvaro Herrera , Peter Smith , Rahila Syed , Peter Eisentraut , =?UTF-8?B?w5ZuZGVyIEthbGFjxLE=?= , japin , Michael Paquier , David Steele , Craig Ringer , Tomas Vondra , Amit Langote , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jul 14, 2021 at 10:50 PM Amit Kapila wrote: > > I think apart from the above, it might be good if we can find what > some other databases does in this regard? > I did a bit of investigation in the case of Oracle Database and SQL Server. (purely from my interpretation of available documentation; I did not actually use the replication software) For Oracle (GoldenGate), it appears that it provides the ability for filters to reference both OLD and NEW rows in replication of UPDATEs: "For update operations, it can be advantageous to retrieve the before values of source columns: the values before the update occurred. These values are stored in the trail and can be used in filters and column mappings" It provides @BEFORE and @AFTER functions for this. For SQL Server, the available replication models seem quite different to that in PostgreSQL, and not all seem to support row filtering. For "snapshot replication", it seems that it effectively supports filtering rows on the NEW values. It seems that the snapshot is taken at a transactional boundary and rows included according to any filtering, and is then replicated. So to include the result of a particular UPDATE in the replication, the replication row filtering would effectively be done on the result (NEW) rows. Another type of replication that supports row filtering is "merge replication", which again seems to be effectively based on NEW rows: "For merge replication to process a row, the data in the row must satisfy the row filter, and it must have changed since the last synchronization" It's not clear to me if there is ANY way to filter on the OLD row values by using some option. If anybody has experience with the replication software for these other databases and I've interpreted the documentation for these incorrectly, please let me know. Regards, Greg Nancarrow Fujitsu Australia