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 1m2vHC-0008Q1-8v for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Jul 2021 12:43:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m2vHA-00069g-O8 for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Jul 2021 12:43:08 +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 1m2vHA-00069N-Dl for pgsql-hackers@lists.postgresql.org; Mon, 12 Jul 2021 12:43:08 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m2vH2-0002Bo-DW for pgsql-hackers@postgresql.org; Mon, 12 Jul 2021 12:43:07 +0000 Received: by mail-ed1-x530.google.com with SMTP id k27so4151397edk.9 for ; Mon, 12 Jul 2021 05:42:59 -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=E31qwxX0r/GeZ0UlwmJWCB6Gi91FDLWAOjhE2AD/v44=; b=hy9GFIC/HhSdkFQXZtsByNW6TICB80V/T0XnsRx2CUMu3he83QfO5YRrj5/7kadmRO O8+sEJQTogAUA2IGRsErbXKzfBIwa6N4m5pm8LwTk7XW6BS8hztUnjhs0Bna2I0RX+/9 Mes7okYZWeZd4GhFd/2NI4+HrmvDZMsnhWOdWZ4ZUerkYLORKF9fqMoO9eeqZmSnDGk9 PrQUv1w0AqjTSnrjoODOXvHI/ORYiimQuqw8xI0E7oh1grg/m7u8Cbark5cgLaCfb7/t xjmoCbECa8dk3rb5piQOXoNYRJSEwG4BD56lcCA2AZxw8hiEfolnj5pZrAIkLDEWZzqQ YMCA== 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=E31qwxX0r/GeZ0UlwmJWCB6Gi91FDLWAOjhE2AD/v44=; b=JfullIBqw7s2YtvgOkfdqW3BQPt/RAAQYNX2RnrzBTZ9RfEhONaeQqtHTJwYshSLdU EXroZt6LEmgJNHddP1nD9+rQLbsP/qRYcJwBDSZm/xKLxKkk//if+3SVdlxsXgGa7IOg fGVI3Xs9PRpKhOSiaAktIli+SuqlvSxUcqcPWv7CFRqNmqDiICVi/1pcPN51PdX5msSA Hp8OZe3rZ9D/xi+gdN8vqFBYMQfdJRoyRgzApOGAiKo3Qmo61yMdLs1pSSwjA4XjXtvF qxH2B23VbUCHAUGkDeQNyYPlYMWMYHYGDUCz2FeMx7Mf1KIDfYdOCUCoMlXeSX7OHuE/ pSjQ== X-Gm-Message-State: AOAM532maQFTi83fG8XNFLRg9EjUp6JhbItbHGE/hEO+dl8GrwXK6Y6G lfGfak3YKl7DQr2d/4q4UfMscen7RGXWe4o7rtfClDcgSlvzaUJKCOdniyLEIXmrmQB3KfC94mC 16Pd9tGFeahbIcjSc4erkExoyATrqNdSdLfgW5U7aKAkd8ayCQJ/sQg37z3KgubwKW63bD1EJPD 0cSrQaaCo6yUIYeQ0ChziDKr8Ka5KOqm5T2vf6WA955ib6fExG12EoIV+PweazTJ8YUKFoqMkiR i/KBvlmCrS2acZmU+BTfLvCCsELhkSONgiWXg== X-Google-Smtp-Source: ABdhPJwybwGRNRnTePJhiwENEu9Lve6AGjLXgoSa/H18Oe1E/2u4jFcIzXcOr0IHOVZ3iGZtcsXMhQ== X-Received: by 2002:aa7:d457:: with SMTP id q23mr41117254edr.324.1626093778202; Mon, 12 Jul 2021 05:42:58 -0700 (PDT) Received: from [10.137.0.19] (ip-86-49-254-183.net.upcbroadband.cz. [86.49.254.183]) by smtp.gmail.com with ESMTPSA id j22sm6364522eje.123.2021.07.12.05.42.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jul 2021 05:42:57 -0700 (PDT) Subject: Re: Column Filtering in Logical Replication To: Rahila Syed , Peter Smith Cc: PostgreSQL-development References: From: Tomas Vondra Message-ID: Date: Mon, 12 Jul 2021 14:42:55 +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 Content-Language: en-US Content-Transfer-Encoding: 8bit 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/12/21 10:32 AM, Rahila Syed wrote: > Hi Peter, > > Hi, I was wondering if/when a subset of cols is specified then does > that mean it will be possible for the table to be replicated to a > *smaller* table at the subscriber side?  > > e.g Can a table with 7 cols replicated to a table with 2 cols? > > table tab1(a,b,c,d,e,f,g) --> CREATE PUBLICATION pub1 FOR TABLE > tab1(a,b)  --> table tab1(a,b) > > ~~ > > > I thought maybe that should be possible, but the expected behaviour > for that scenario was not very clear to me from the thread/patch > comments. And the new TAP test uses the tab1 table created exactly the > same for pub/sub, so I couldn't tell from the test code either. > >   > Currently, this capability is not included in the patch. If the table on > the subscriber > server has lesser attributes than that on the publisher server, it > throws an error at the  > time of CREATE SUBSCRIPTION. > That's a bit surprising, to be honest. I do understand the patch simply treats the filtered columns as "unchanged" because that's the simplest way to filter the *data* of the columns. But if someone told me we can "filter columns" I'd expect this to work without the columns on the subscriber. > About having such a functionality, I don't immediately see any issue > with it as long > as we make sure replica identity columns are always present on both > instances. Yeah, that seems like an inherent requirement. > However, need to carefully consider situations in which a server > subscribes to multiple  > publications,  each publishing a different subset of columns of a table.   >   Isn't that pretty much the same situation as for multiple subscriptions each with a different set of I/U/D operations? IIRC we simply merge those, so why not to do the same thing here and merge the attributes? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company