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 1m3fhB-0007aW-LG for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 14:17:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3fhA-0006lm-Hw for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 14:17:04 +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 1m3fhA-0006le-A0 for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 14:17:04 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m3fh6-0002R3-Mx for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 14:17:03 +0000 Received: by mail-wm1-x329.google.com with SMTP id q18-20020a1ce9120000b02901f259f3a250so1542993wmc.2 for ; Wed, 14 Jul 2021 07:17:00 -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=LlXzXSFiWS3NUKvcg+lDns462UtZqjwFWbilfr7q4/w=; b=OCjSOINXcuGLJmcsq/Y0MhHlqxEZ9FK6KlaClasZSiJ/4P8scKAG0Bk6eUGNI5OdR9 cUsQvqtWJep5OfprNzRo4jmWaiAvK+7j/WnawU7Q9V1Cm1Sqfly7z9NLdLqyY60noix6 Y2BSL49OJ+ys3FDjxVAbq3ZiM3fkGjWEm0MQ6XNImj0bCsjPqU0TBmZYC/BWESh14mWZ JEi/jmbpUI8+spsZUqGhjy+1scghZm+v8mrXzAzxA5RYdYaxcKO86wt9+2DDN5j29Kck jQC1A822xwOCMN3rM0eXHvcGvXwHy0bgvvxnKcMjVVzc5J8TsMvB+96e3OqUz0qf8AQ1 aSLA== 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=LlXzXSFiWS3NUKvcg+lDns462UtZqjwFWbilfr7q4/w=; b=MqAQ+FKdPYUBYD44S5KkdFiTNQ8xDcG6FygiWVTQtDZOFEZcwSvEivelYInHza6zK1 Zu2knQJt0BxBxwhOq7zFy7BLNYyVvrvAENEaQrR9oVcXLyDbuoGJ/fAITNZCcY1ti3HF XCVN/kN2Z0aH/CACSswRgmEAaTBkdCyaCWB3OtWDYdtLKV2D+rGYYb6WyHFPhLHwenhl 8nHMeNWWGK0iFMuBLP5u66JtDkaA56isuwXRb9yx2TSRx6XOirbK4ou8DgVD5nqZ111g 5sVWbUhl6luSqA/h/Uv+AomnuqPAjTWGj4cvqsv20qNUNwaIRE28haNj0RBrIYOM2zHM Lplw== X-Gm-Message-State: AOAM531hpGgx7N9c6pA7sXhy+mNyvcmD5cRjvu4/myj/wvMmVbJhRnPJ v6kY4wU00/1JmF/w+mcvsJjekJv2B4dVGzrZlFmYmZYQq2cRF6L0gQkWmPEfhEqeiMjOgnHJIWI AmbNOq7uk9i/iPnJif9+Kypbo5XVfIu5BCpE6gpm4EbG+3AMU8no8+u5nSFgCE86y6cTE1E2Zre JKGh5uR0/xD5VYiTZ2yKvkMail9SQQmkCbfisONH57Vp8/0Th/zHGfIzyFdK2SP6avsJL6ROZay WXf55BeBq3jGFfz5MLq23FRn0gEsLdV5aU7PaeNwqtw1i8ACoWz9A== X-Google-Smtp-Source: ABdhPJzmV2NluHmTKH4w4+WcoB4CrX7lmiYwMxpf5ikF+chMv7ZA4GmR2QIh+lc4Lk5AcGQU8HSXKQ== X-Received: by 2002:a1c:1bd4:: with SMTP id b203mr4386286wmb.171.1626272219055; Wed, 14 Jul 2021 07:16:59 -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 p2sm2191595wmg.6.2021.07.14.07.16.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jul 2021 07:16:58 -0700 (PDT) Subject: Re: row filtering for logical replication To: Alvaro Herrera , Dilip Kumar Cc: Amit Kapila , Euler Taveira , Peter Smith , Rahila Syed , Peter Eisentraut , =?UTF-8?B?w5ZuZGVyIEthbGFjxLE=?= , japin , Michael Paquier , David Steele , Craig Ringer , Tomas Vondra , Amit Langote , PostgreSQL Hackers References: <202107141401.zj6zabriddtt@alvherre.pgsql> From: Tomas Vondra Message-ID: <7ee3ec83-3e60-ba69-3ee9-a190a4b7714e@enterprisedb.com> Date: Wed, 14 Jul 2021 16:16:56 +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: <202107141401.zj6zabriddtt@alvherre.pgsql> 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:01 PM, Alvaro Herrera wrote: > On 2021-Jul-14, Dilip Kumar wrote: > >> I think for insert we are only allowing those rows to replicate which >> are matching filter conditions, so if we updating any row then also we >> should maintain that sanity right? That means at least on the NEW rows >> we should apply the filter, IMHO. Said that, now if there is any row >> inserted which were satisfying the filter and replicated, if we update >> it with the new value which is not satisfying the filter then it will >> not be replicated, I think that makes sense because if an insert is >> not sending any row to a replica which is not satisfying the filter >> then why update has to do that, right? > > Right, that's a good aspect to think about. > I agree, that seems like a reasonable approach. The way I'm thinking about this is that for INSERT and DELETE it's clear which row version should be used (because there's just one). And for UPDATE we could see that as DELETE + INSERT, and apply the same rule to each action. On the other hand, I can imagine cases where it'd be useful to send the UPDATE when the old row matches the condition and new row does not. > I think the guiding principle for which tuple to use for the filter is > what is most useful to the potential user of the feature, rather than > what is the easiest to implement. > +1 -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company