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 1mD4cd-0000oG-KT for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Aug 2021 12:43:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mD4cb-0004tr-L2 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Aug 2021 12:43:13 +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 1mD4cb-0004tj-BN for pgsql-hackers@lists.postgresql.org; Mon, 09 Aug 2021 12:43:13 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mD4cY-0007nE-P9 for pgsql-hackers@lists.postgresql.org; Mon, 09 Aug 2021 12:43:13 +0000 Received: by mail-lf1-x131.google.com with SMTP id w20so6958325lfu.7 for ; Mon, 09 Aug 2021 05:43:10 -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=V5N1YOjLbhS/9VmN7/E13kMklT8f3spldEdLzBwOVpU=; b=u7hFroDgdh6Z9NATSlcTHsfe8H7uH4dCPW5n4ugKXLoobWQ7JjBXoeGwGAFNs69X+S aBoiOWusGqmux252nkiFiLwAUNt0aJD9aDMeU1hXjmwnQVYeMnxxdFB0k5g3KIJrhOAV 3j8b144Tl2fT4TFYMcW4MtGGUPYzGqJ3HkUomgzSWgEzVPKDdpuaFMcsNXlJWzwbA4T2 pDjPRQd2v0sBm0WNFjKUhnIEZIXg1S7r3d9sP18OJw4IhVd8aZhgn0MEoYrWydGLNJaE n6nJqkilhd4nfRExbKR7dNtSiVtjFk3qbvTGo5dzfGJwyAWcZ12oBnVxGz4pOTdxVKgD fVMg== 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=V5N1YOjLbhS/9VmN7/E13kMklT8f3spldEdLzBwOVpU=; b=b2Ut9zkf7A7neHAb7BW8J8BW0Ayoqs3pjozIgaarF4V5veWjyeerwAxkYmR5Q3OC3r x8QM/yfs/1UkUvZ3VYqNz9o5mV5UbSDA339jxvGI6bgHRyCzboqkHemzoXMNk2icWU6N ISDHK3Q45cr41kY6VrwFEzTx6b4FuFPb9UZdzyEAVUs/Rl3ERO9V85HoH85ODZKClsrd qClk3yM/ckPV398xi46oOajx/0GxkcMsE2wG+JnI/crhWB+aiVhH7+HJgGvv+x2Jjsrz qmK95sWf/ey9nXNksTXox4CuMRThXyTaf1S4Z0EGsc+UckIz7uovHV2cV8+EMKtOaRnB D2EA== X-Gm-Message-State: AOAM532qQwcqaW0pVC/tp3magRfXzXxdzTjaMb7MzHghgAei0EtiI7K3 KRvYiDn1FtgNjHMU7g9oTIWCoFkrtkE1H9zi6M8= X-Google-Smtp-Source: ABdhPJx0VzShB+T8/ghOjBAGfauuJUGlCEQ4N0TxtVaD6SFEKdu3TxhLwhPIPDMsRHX1j/XOs7sBqcr+TTmMOTSTYbo= X-Received: by 2002:ac2:5926:: with SMTP id v6mr7264742lfi.363.1628512988989; Mon, 09 Aug 2021 05:43:08 -0700 (PDT) MIME-Version: 1.0 References: <202107162135.m5ehijgcasjk@alvherre.pgsql> In-Reply-To: From: Dilip Kumar Date: Mon, 9 Aug 2021 18:12:52 +0530 Message-ID: Subject: Re: row filtering for logical replication To: Amit Kapila Cc: "houzj.fnst@fujitsu.com" , Tomas Vondra , Alvaro Herrera , Greg Nancarrow , Euler Taveira , Peter Smith , Peter Eisentraut , =?UTF-8?B?w5ZuZGVyIEthbGFjxLE=?= , japin , Michael Paquier , David Steele , Craig Ringer , Tomas Vondra , Amit Langote , PostgreSQL Hackers , Rahila Syed Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Aug 3, 2021 at 4:25 PM Amit Kapila wrote: > > On Tue, Jul 27, 2021 at 9:56 AM Dilip Kumar wrote: > > > Yeah, that's a big problem, seems like the expression evaluation > > machinery directly going and detoasting the externally stored data > > using some random snapshot. Ideally, in walsender we can never > > attempt to detoast the data because there is no guarantee that those > > data are preserved. Somehow before going to the expression evaluation > > machinery, I think we will have to deform that tuple and need to do > > something for the externally stored data otherwise it will be very > > difficult to control that inside the expression evaluation. > > > > True, I think it would be possible after we fix the issue reported in > another thread [1] where we will log the key values as part of > old_tuple_key for toast tuples even if they are not changed. We can > have a restriction that in the WHERE clause that user can specify only > Key columns for Updates similar to Deletes. Then, we have the data > required for filter columns basically if the toasted key values are > changed, then they will be anyway part of the old and new tuple and if > they are not changed then they will be part of the old tuple. Right. I have > not checked the implementation part of it but theoretically, it seems > possible. Yeah, It would be possible to because at least after fixing [1] we would have the required column data. The only thing I am worried about is while applying the filter on the new tuple the toasted unchanged key data will not be a part of the new tuple. So we can not directly call the expression evaluation machinary, basically, somehow we need to deform the new tuple and then replace the data from the old tuple before passing it to expression evaluation. Anyways this is an implementation part so we can look into that while implementing. If my understanding is correct then it becomes necessary to > solve the other bug [1] to solve this part of the problem for this > patch. Right. The other possibility is to disallow columns (datatypes) that > can lead to toasted data (at least for Updates) which doesn't sound > like a good idea to me. Yeah, that will be a big limitation, then we won't be able to allow expression on any varlena types. Do you have any other ideas for this problem? As of now no other better idea to suggest. [1] - https://www.postgresql.org/message-id/OS0PR01MB611342D0A92D4F4BF26C0F47FB229%40OS0PR01MB6113.jpnprd01.prod.outlook.com -- Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com