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 1nSeVL-0002Nz-Gn for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Mar 2022 12:36:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nSeVJ-00084z-C2 for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Mar 2022 12:36:21 +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 1nSeVI-0007zr-MH for pgsql-hackers@lists.postgresql.org; Fri, 11 Mar 2022 12:36:21 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nSeVF-0003Gx-E8 for pgsql-hackers@postgresql.org; Fri, 11 Mar 2022 12:36:19 +0000 Received: by mail-ej1-x62c.google.com with SMTP id gb39so18741323ejc.1 for ; Fri, 11 Mar 2022 04:36:17 -0800 (PST) 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=b9zXOxEDetlgRj7NzpFEV2Ei2tPZx0yUJb9k1NeIdRA=; b=JBJcICR2cKki0CiRMQ9hcimqeeCL8a2UJf2Jig3GLcwAsIVEiNnwSj3Fsfk/WDL2N9 NcTwPpFaf+UIlwZUs/mfEbHOALFuttDZqEBIVwHHVt6dWx4nk4MpO+gm7kcJGYGDBLvS ETfCwW01xEzc0c9aAw40fCO90RA80ygWvPsRzE6aS/ffbSLrM/2S1bZXh/XMJE5NI3Dn 0EPcScvOpHp6oqoaKNwmCP3SaAuFpRMtYecI7qo+npbyxGrci6oxnHGjXEIU4x8YaffN nod+0ZQVL3dVlNucGju2JostgUkWmRD2/INhIrgjVhla+lzbHu0Sp+zNFgsH12jpbain T2ZQ== 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=b9zXOxEDetlgRj7NzpFEV2Ei2tPZx0yUJb9k1NeIdRA=; b=aVc3JN1hz3Dpt/VtLTK7MVtl1xOHZpkSCDlWuurZpD5wTDmPvhNFOAgmCcVR+6OGJ6 pp349FxpBeqlgkfZruDejS3TOakdP/jAFnKOFJB+OvOWgnP9qdAw0O8rJ5wzqf3N60kM /curEmOB5rBpz44fXmh5zjpVpXoHvb5nREPVT8n0LL0fiqnciXrrQaWqQq8vvVvPTt5j quAZXiVqm2kvIG7BPdQAmN4hBT68qIBNPhn8buUnlfaObnM6ST6F7drD5pZyHOguOduy rtyTEJ3tdh0kcvp10E+j16l0K40uv4ihvpnr1g8jCBJoUsAEemHphmf3qC4hCrxc5ucw Pd2Q== X-Gm-Message-State: AOAM532oP+G9ytsqbU2ddkcl2GOAIwWfBWmLSpPvsIEsYcvIqOShNIOE KAXxHpeG/XyGRyl3PAc2TCcXnsX1gzEAXSTHRFxKhbHadldiVWKfiwqNgs2j/itJ6veY65Yevqe JYjQMG3620KOKlp/CIzhvNQ7ciVxHeXApfMpPPNWZb7TNm7flQW8HxJ6x3LNQeuD7io77CH38zZ lCQ8QcUnJjDHNGHlRan/QyWWlPEQt6bjtKc09j X-Google-Smtp-Source: ABdhPJyjiz/q8e3OvJv4wXAPkfD5UA7QA0sECRTfmZtWTAhZyIm4IGbuBceKc3V47gELPMx0cURRVg== X-Received: by 2002:a17:906:d205:b0:6d1:4446:d950 with SMTP id w5-20020a170906d20500b006d14446d950mr8176441ejz.702.1647002175715; Fri, 11 Mar 2022 04:36:15 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-251-241.net.upcbroadband.cz. [86.49.251.241]) by smtp.gmail.com with ESMTPSA id c4-20020a170906340400b006d077e850b5sm2875167ejb.23.2022.03.11.04.36.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Mar 2022 04:36:14 -0800 (PST) Message-ID: <3536d621-e3fc-c248-c03b-dd7bd0cfc4fc@enterprisedb.com> Date: Fri, 11 Mar 2022 13:36:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: Column Filtering in Logical Replication Content-Language: en-US To: "wangw.fnst@fujitsu.com" , "houzj.fnst@fujitsu.com" , Amit Kapila Cc: Peter Eisentraut , Alvaro Herrera , Justin Pryzby , Rahila Syed , Peter Smith , pgsql-hackers , "shiy.fnst@fujitsu.com" References: <202201120041.p24wvsfcsope@alvherre.pgsql> <78b8d385-57cb-9a3f-cfe5-9f300f15eced@enterprisedb.com> <822a8e40-287c-59ff-0ea9-35eb759f4fe6@enterprisedb.com> From: Tomas Vondra In-Reply-To: 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 3/11/22 08:05, wangw.fnst@fujitsu.com wrote: > On Fri, Mar 11, 2022 at 9:57 AM Tomas Vondra wrote: >> > Hi Tomas, > Thanks for your patches. > > On Mon, Mar 9, 2022 at 9:53 PM Tomas Vondra wrote: >> On Wed, Mar 9, 2022 at 6:04 PM Amit Kapila wrote: >>> On Mon, Mar 7, 2022 at 11:18 PM Tomas Vondra wrote: >>>> On Fri, Mar 4, 2022 at 6:43 PM Amit Kapila wrote: >>>>> Fetching column filter info in tablesync.c is quite expensive. It >>>>> seems to be using four round-trips to get the complete info whereas >>>>> for row-filter we use just one round trip. I think we should try to >>>>> get both row filter and column filter info in just one round trip. >>>>> >>>> >>>> Maybe, but I really don't think this is an issue. >>>> >>> >>> I am not sure but it might matter for small tables. Leaving aside the >>> performance issue, I think the current way will get the wrong column >>> list in many cases: (a) The ALL TABLES IN SCHEMA case handling won't >>> work for partitioned tables when the partitioned table is part of one >>> schema and partition table is part of another schema. (b) The handling >>> of partition tables in other cases will fetch incorrect lists as it >>> tries to fetch the column list of all the partitions in the hierarchy. >>> >>> One of my colleagues has even tested these cases both for column >>> filters and row filters and we find the behavior of row filter is okay >>> whereas for column filter it uses the wrong column list. We will share >>> the tests and results with you in a later email. We are trying to >>> unify the column filter queries with row filter to make their behavior >>> the same and will share the findings once it is done. I hope if we are >>> able to achieve this that we will reduce the chances of bugs in this >>> area. >>> >> >> OK, I'll take a look at that email. > I tried to get both the column filters and the row filters with one SQL, but > it failed because I think the result is not easy to parse. > > I noted that we use two SQLs to get column filters in the latest > patches(20220311). I think maybe we could use one SQL to get column filters to > reduce network cost. Like the SQL in the attachment. > I'll take a look. But as I said before - I very much prefer SQL that is easy to understand, and I don't think the one extra round trip is an issue during tablesync (which is a very rare action). regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company