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 1nlGZr-0004gz-04 for pgsql-hackers@arkaria.postgresql.org; Sun, 01 May 2022 20:53:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nlGZp-00089i-Kf for pgsql-hackers@arkaria.postgresql.org; Sun, 01 May 2022 20:53:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nlGZo-00089Y-QS for pgsql-hackers@lists.postgresql.org; Sun, 01 May 2022 20:53:57 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nlGZi-0007ye-2S for pgsql-hackers@lists.postgresql.org; Sun, 01 May 2022 20:53:55 +0000 Received: by mail-ej1-x631.google.com with SMTP id i19so24553169eja.11 for ; Sun, 01 May 2022 13:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=l+e5sabGAkMbtw/2LB6RD11qXRhTWJ46FebzubbnL2A=; b=VFh+V9Nw3AVnvQS9p0uX5aDKt2oF5WhwInoV66hbwIA0UPp/s5A8Iouh7vnvbwC+vF O2uuws8iYM3XQcjaefOVcAsMR83UtjfqLZbPPZDwX55oHkYGfRAjSu2A4UPfrAJ/UnKW o7OCo7GyCtrT75qjN/zVog8cbLZFaZRgq2PXNBZtpKbVYtK5QXuounx0grA1abBGwIFW QKJOoiVlFuckafeZ3Ux60X/BlTqmPJtJukHglJCCXj/9Z46BRS0jnYjbgUOv2y8Amx8f +kCC1e1l0F4d+vvf+ePyveavv3sjpH0+yHKba+qSaQyTpK5x+QWtHkxr08INtac387CQ M3sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=l+e5sabGAkMbtw/2LB6RD11qXRhTWJ46FebzubbnL2A=; b=VHhpGXSXzJAY38u2fILPtzSXtBxbVdHwyb8vPA1juVxZfPnLb7Qhywi2x1aaO5jkz7 rFHhvDSWXxIDhDdVEAyThCHy9tC5mWVpd9l4feAVHg+NIaEDuOze9IOZAB/I92dyFUR5 neqTVixxXgSqnhw0s0n4W3kEt/m3N+rm0sxVTSGEo88zVHwg8JAfnyXTLt152xdOgeiq MCCrPBaau01Jk3yDKs8NiW4phr9Lk/b5PnYbKftnG2DBfs+5mUvMtsQl8SRvbVED18l3 FGrDRZd7jCSZGCtj7sNOQd2/xvzRmbnCD3zL0jHnTgljNPF95aVfDGCChchtyQ8QrG+t 5gaw== X-Gm-Message-State: AOAM533jA1E3zXQ3TnpDXsLQm2fzD99Vg84UtgoCRf+TyW3dohVyHDZs irPx+8/1ZPGWw7CjuKK0lkA4HDHXyHYXBkjpTv5lmrra1e6qMYvmawqEckBrEeznARVcigDy8KW pG1kw0CdFeZ3XZyBXVljzzTB4u0xEnwZmvM1WRfnP7Aubrc9vw8BElvkSe/O9ted1Gd2ZBLZw87 YpxOZ1Kfnb23JUpaD4g42G7iJZM0JPiUG8QXG7ehjhVnpdD+x5eIKe X-Google-Smtp-Source: ABdhPJz06QFxrQ2k9qrLZH3r6TEU8j8f5gANA5zAeEuHn8mq/bALFTdvPVFNhLA3ocaUBuy5R2fxPw== X-Received: by 2002:a17:907:7d93:b0:6da:8f57:68fa with SMTP id oz19-20020a1709077d9300b006da8f5768famr8751063ejc.42.1651438427493; Sun, 01 May 2022 13:53:47 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-250-165.net.upcbroadband.cz. [86.49.250.165]) by smtp.gmail.com with ESMTPSA id eg51-20020a05640228b300b0042617ba63casm5613166edb.84.2022.05.01.13.53.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 May 2022 13:53:47 -0700 (PDT) Message-ID: <8ccaee59-0333-b4d9-c294-e2f6633853ae@enterprisedb.com> Date: Sun, 1 May 2022 22:53:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: bogus: logical replication rows/cols combinations Content-Language: en-US To: Alvaro Herrera Cc: Amit Kapila , Pg Hackers References: <202204300928.3rnkdtfj3bmv@alvherre.pgsql> From: Tomas Vondra In-Reply-To: <202204300928.3rnkdtfj3bmv@alvherre.pgsql> Content-Type: text/plain; charset=UTF-8 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 4/30/22 11:28, Alvaro Herrera wrote: > On 2022-Apr-28, Tomas Vondra wrote: > >> Attached is a patch doing the same thing in tablesync. The overall idea >> is to generate copy statement with CASE expressions, applying filters to >> individual columns. For Alvaro's example, this generates something like >> >> SELECT >> (CASE WHEN (a < 0) OR (a > 0) THEN a ELSE NULL END) AS a, >> (CASE WHEN (a > 0) THEN b ELSE NULL END) AS b, >> (CASE WHEN (a < 0) THEN c ELSE NULL END) AS c >> FROM uno WHERE (a < 0) OR (a > 0) > > I've been reading the tablesync.c code you propose and the idea seems > correct. (I was distracted by wondering if a different data structure > would be more appropriate, because what's there looks slightly > uncomfortable to work with. But after playing around I can't find > anything that feels better in an obvious way.) > > (I confess I'm a bit bothered by the fact that there are now three > different data structures in our code called PublicationInfo). > True. I haven't really thought about naming of the data structures, so maybe we should name them differently. > I propose some comment changes in the attached patch, and my > interpretation (untested) of the idea of optimizing for a single > publication. (In there I also rename logicalrep_relmap_free_entry > because it's confusing. That should be a separate patch but I didn't > split it before posting, apologies.) > >> There's a couple options how we might optimize this for common cases. >> For example if there's just a single publication, there's no need to >> generate the CASE expressions - the WHERE filter will do the trick. > > Right. > OK, now that we agree on the approach in general, I'll look into these optimizations (and the comments from your patch). regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company