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 1oDst1-0007zm-EI for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jul 2022 19:28:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oDst0-0001R4-BA for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Jul 2022 19:28:02 +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 1oDst0-0001Qv-2E for pgsql-hackers@lists.postgresql.org; Tue, 19 Jul 2022 19:28:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDssy-0006DL-1L for pgsql-hackers@lists.postgresql.org; Tue, 19 Jul 2022 19:28:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 26JJRuCB1297001; Tue, 19 Jul 2022 15:27:56 -0400 From: Tom Lane To: Tomas Vondra cc: Andres Freund , Fujii Masao , Robert Haas , PostgreSQL Hackers Subject: Re: postgres_fdw: using TABLESAMPLE to collect remote sample In-reply-to: <4e1c9731-8f8a-8b3e-17b8-d4c81b70df70@enterprisedb.com> References: <151e835f-55d6-ddbc-b5b4-07ee606aba44@enterprisedb.com> <2080021.1644601183@sss.pgh.pa.us> <2082308.1644602761@sss.pgh.pa.us> <60c4dc7c-82e8-ab04-a938-d7b7c5ee75f0@enterprisedb.com> <84afe85f-2aa0-5aef-fa4a-59759afc03fb@enterprisedb.com> <76202fae-0c34-4f49-e3a0-1071c3fcf9e1@enterprisedb.com> <2d679fff-fb74-8ad1-fe57-094563f2aa55@enterprisedb.com> <20220322011820.vlz3l577elz46wln@alap3.anarazel.de> <3998908.1658008664@sss.pgh.pa.us> <113b8f5b-eec6-ea60-8508-439f2692887c@enterprisedb.com> <782558.1658169910@sss.pgh.pa.us> <4e1c9731-8f8a-8b3e-17b8-d4c81b70df70@enterprisedb.com> Comments: In-reply-to Tomas Vondra message dated "Tue, 19 Jul 2022 21:07:08 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1296999.1658258876.1@sss.pgh.pa.us> Date: Tue, 19 Jul 2022 15:27:56 -0400 Message-ID: <1297000.1658258876@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tomas Vondra writes: > I we want to improve sampling for partitioned cases (where the foreign > table is just one of many partitions), I think we'd have to rework how > we determine sample size for each partition. Now we simply calculate > that from relpages, which seems quite fragile (different amounts of > bloat, different tuple densities) and somewhat strange for FDW serves > that don't use the same "page" concept. > So it may easily happen we determine bogus sample sizes for each > partition. The difficulties when calculating the sample_frac is just a > secondary issue. > OTOH the concept of a "row" seems way more general, so perhaps > acquire_inherited_sample_rows should use reltuples, and if we want to do > correction it should happen at this stage already. Yeah, there's definitely something to be said for changing that to be based on rowcount estimates instead of physical size. I think it's a matter for a different patch though, and not a reason to hold up this one. regards, tom lane