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 1m3gKM-0000oM-0Y for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 14:57:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3gKK-0004EM-UK for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 14:57:32 +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 1m3gKK-0004EE-MR for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 14:57:32 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m3gKH-0002l9-3l for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 14:57:32 +0000 Received: by mail-wm1-x32c.google.com with SMTP id f190so211449wmf.4 for ; Wed, 14 Jul 2021 07:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=KM/2MMWKFAwF0m23MvnhrrEGdCkaKD6XdOShjUD5FXc=; b=IsiRdVnpBDJDUKQyfKa3moOY7pjaDGxWhuLAS1TdDzy0ECr/0krqrWdeFl+QF7IdwU j7o55eWR5EUmAjXlYoE7Sd6lv5lplwZls5l0DwVb2/AH/1fhUa1k9rS3FXOWcuZAh7Bn CZKPtEZiNUqIbIn9aoB8hjIlQW4Rj2inMz1XN8rBQ6iZDwcGT90fq1WpmDXsQ+j5yaJq SWJVDoWM4RcgdYbK7x/MWEjtlfuLX1EWN+k6FA4UeAL4gKItR8ZG3opaqEh38w4ReqNj E66YTNTzOPICeb0VFjRGPwG3/l4LLdpxeZpW6sCVwL5FTJvN5mKighYAE5jBsz2L+5pD r7RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KM/2MMWKFAwF0m23MvnhrrEGdCkaKD6XdOShjUD5FXc=; b=GGowvJg/TtNGO7+XbsuYG00zgOfXHToubdV1nvaRrZhqkeSIIooztd2jRh3b3nxzVY Far7Bj12Vhx/rSMP1A7/v64gcJQ5bA4gG0MijmwGoMXodpK/8cfOmo8CPTH7J3Hny0yO TeyYCMhm6UR3Je7i42Bh0LvqqyWrO8ljq5oY3d+Kfbe4nAjLnF3uIyUbsuALLw6wVjZh Gvy2hF/+T/PUQNX6zv0s23Al5IY+QQ2/4DMjbX7PSQ5pYaCsE2MlaiiJe2lpRbcNpLYc YsVG5+FLp3Y5xxLpw6z6mIWB5xp7A0GuYyHY+qIJutSKF5dN2bcCUgR+FY31My9is2gF 2XGQ== X-Gm-Message-State: AOAM532nk3nL7dBBFezYvQ1oXRFWOKI74DrY0xSjhCopDs8PgJtgGKt0 7dUN323l/5SowdqxmUuji+FnexpOHytWU1kURPcTE/PNFpYuckES/7tuxR/CRxYnzMMJX9w14s0 8jrdWvPWZ1wOLtPUS5J0nNmuf+8PWQbheQTx1Cb+PrIzwqV0VQlyzi7yrH1UrMia7bzez9wyLYU EP5dWL3FR42n156LRzY+Lz/PTbZTrUlVspl9cSm975DEMmr4QRcZdcT3oNw9VXpHgNSy50Q/Yew fbH9rDLiSxF0dKdGyIq7Qju2SuqTKKiLBsF3KH8RUc055+6aqhCwg== X-Google-Smtp-Source: ABdhPJzmHhAbGLtVFhQ5b1HMxBFS8Q06F2xCZf2zsupHy96COT4F9JgL34xeTH3AoXAsg2/vnXNMwQ== X-Received: by 2002:a1c:730d:: with SMTP id d13mr4767118wmb.129.1626274647544; Wed, 14 Jul 2021 07:57:27 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-254-183.net.upcbroadband.cz. [86.49.254.183]) by smtp.gmail.com with ESMTPSA id l14sm2780169wrs.22.2021.07.14.07.57.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jul 2021 07:57:27 -0700 (PDT) Subject: Re: row filtering for logical replication To: Dilip Kumar Cc: Amit Kapila , 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 References: <202107132106.wvjgvjgcyezo@alvherre.pgsql> <48e13621-10f7-49ef-bcbe-ed530195efd2@www.fastmail.com> From: Tomas Vondra Message-ID: <7022de8a-0ba0-9af3-3be6-76ab5f7fbe39@enterprisedb.com> Date: Wed, 14 Jul 2021 16:57:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/14/21 4:48 PM, Dilip Kumar wrote: > On Wed, Jul 14, 2021 at 8:04 PM Tomas Vondra > wrote: >> > >> Perhaps the best way forward is to stick to the approach that INSERT >> uses new, DELETE uses old and UPDATE works as DELETE+INSERT (probably), >> and leave anything fancier (like being able to reference both versions >> of the row) for a future patch. > > If UPDATE works as DELETE+ INSERT, does that mean both the OLD row and > the NEW row should satisfy the filter, then only it will be sent? > That means if we insert a row that is not satisfying the condition > (which is not sent to the subscriber) and later if we update that row > and change the values such that the modified value matches the filter > then we will not send it because only the NEW row is satisfying the > condition but OLD row doesn't. I am just trying to understand your > idea. Or you are saying that in this case, we will not send anything > for the OLD row as it was not satisfying the condition but the > modified row will be sent as an INSERT operation because this is > satisfying the condition? > Good questions. I'm not sure, I probably have not thought it through. So yeah, I think we should probably stick to the principle that what we send needs to match the filter condition, which applied to this case would mean we should be looking at the new row version. The more elaborate scenarios can be added later by a patch allowing to explicitly reference the old/new row versions. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company