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 1mwHC0-000522-30 for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Dec 2021 05:14:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mwHBx-0000c2-SC for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Dec 2021 05:14:33 +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 1mwHBx-0000ba-7z for pgsql-hackers@lists.postgresql.org; Sun, 12 Dec 2021 05:14:33 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mwHBp-0005Wd-QS for pgsql-hackers@postgresql.org; Sun, 12 Dec 2021 05:14:31 +0000 Received: by mail-ed1-x52b.google.com with SMTP id y12so41272619eda.12 for ; Sat, 11 Dec 2021 21:14:25 -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=ibpyOcimhi4U2zBWdX92VMq5YRMiN2bFFAMHZsNcZM0=; b=ZKrenilsfk5xL+o2rCOtbzW+aUf5eE0mPfFYVxhX+8NtVk7Phu8Znmg/S5PudhOxvm k+Q4bc4gCOtAv5NKmB5Zr2HwEHaqSdCLg5J9Wcu+H+DJZr8zLZOs+AHhUxyetSJQ3mUy 0xr25T4dgW1Ay5G50GKnYqej5FeIKRqsKhhpOgteJatvir2eTl0TmVP1nlcMsxfgwEWF AhSxey+xR+PQuajxhvis/utfzmN3p71SHloz0FWdTSqaMPb1gMsp5rf8TWI7mnB/NLFy W9uT/ig6lWKzNTtv/leSQb+9SBL+8V5OkPT+uT0SFnlOTlXRoGZb01AwvJrheaA8Hoiq AjoA== 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=ibpyOcimhi4U2zBWdX92VMq5YRMiN2bFFAMHZsNcZM0=; b=tftlclK3nTH9OYSH8Cgw0eWLKUs2D/6zMhzxTLtVWyJDAyFAUBdXqlfU8tx0RFJVbl U/8VxSsGNgll2egKIDhbr/KKem3kpUtKUPGU9CqQIQi8Z5p+rhI4PgldK9/4AxIXww+o 7E579JOtQca7zjQsRuqynRRIvZpP5RdALabLr6squxj981GxU/AOCfoKztgI734QPTYn RvPNHdeFFQNFWGaWSgWrZUO21sleePNsqT8wFzXgJBvaA3L9YgfBbZOnpHu0IQrCqj8E yd0j5KyaDFLFRc5WJLzuv8C5r4o2V4B2W4Z0NtTDTmCCTSsW+g217/mtMO0zZtr7++QW B/WQ== X-Gm-Message-State: AOAM532lu1ceEF5kJlGcyt7Sr8kP9opCyb7Zx0H2VeAdMbEMYugHwmRp QD/9A/OlLN13kVweAvzuGsCuv28GSs+UF91MWGaAPHSL9/GbxKthQuWhdpPSVjclw9vkfylanHc HPoEh9NZpqLjcCDdZXTKFNyVOxh9E56WOHWN+AMpsGoAZ4G7cBZc+N0MhCHk1MeLHBcy7w58X1d 0U2CFEBaZV8E3lEs3Fe/LFHiRxvPyqcP2ru05R X-Google-Smtp-Source: ABdhPJwOhpfwMMwti27UbZ+HFFw4Xbhb3Bi7kfW1XneTj5txMKMg6l9rKn7OZCL2onZXFt/HLp6UPQ== X-Received: by 2002:a17:906:eda3:: with SMTP id sa3mr35823146ejb.51.1639286063208; Sat, 11 Dec 2021 21:14:23 -0800 (PST) Received: from [10.137.0.19] (ip-86-49-251-241.net.upcbroadband.cz. [86.49.251.241]) by smtp.gmail.com with ESMTPSA id nc29sm3911433ejc.3.2021.12.11.21.14.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Dec 2021 21:14:22 -0800 (PST) Message-ID: Date: Sun, 12 Dec 2021 06:14:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: extended stats on partitioned tables Content-Language: en-US To: Zhihong Yu Cc: Justin Pryzby , Jaime Casanova , PostgreSQL-development References: <20210923212624.GI831@telsasoft.com> <20210925223152.GA7877@telsasoft.com> <20210926202550.GA831@telsasoft.com> <20211007202646.GA9522@ahch-to> <20211007224543.GH27491@telsasoft.com> <46f37069-55cb-db6a-a15a-e351a2606592@enterprisedb.com> <20211103231904.GP17618@telsasoft.com> <689accb1-76e8-5115-6ed0-336749cdca57@enterprisedb.com> <20211203052411.GU17618@telsasoft.com> <8052505e-2dd2-e8cb-26c9-cbb5dff7d750@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 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 12/12/21 05:38, Zhihong Yu wrote: > > > On Sat, Dec 11, 2021 at 8:17 PM Tomas Vondra > > > wrote: > > Hi, > > Attached is a rebased and cleaned-up version of these patches, with more > comments, refactorings etc. Justin and Zhihong, can you take a look? > > > 0001 - Ignore extended statistics for inheritance trees > > 0002 - Build inherited extended stats on partitioned tables > > Those are mostly just Justin's patches, with more detailed comments and > updated commit message. I've considered moving the rel->inh check to > statext_clauselist_selectivity, and then removing the check from > dependencies and MCV. But I decided no to do that, because someone might > be calling those functions directly (even if that's very unlikely). > > The one thing bugging me a bit is that the regression test checks only a > GROUP BY query. It'd be nice to add queries testing MCV/dependencies > too, but that seems tricky because most queries will use per-partitions > stats. > > > 0003 - Add stxdinherit flag to pg_statistic_ext_data > > This is the patch for master, allowing to build stats for both inherits > flag values. It adds the flag to pg_stats_ext_exprs view to, reworked > how we deal with iterating both flags etc. I've adopted most of the > Justin's fixup patches, except that in plancat.c I've refactored how we > load the stats to process keys/expressions just once. > > It has the same issue with regression test using just a GROUP BY query, > but if we add a test to 0001/0002, that'll fix this too. > > > 0004 - Refactor parent ACL check > > Not sure about this - I doubt saving 30 rows in an 8kB file is really > worth it. Maybe it is, but then maybe we should try cleaning up the > other ACL checks in this file too? Seems mostly orthogonal to this > thread, though. > > > Hi, > For patch 3, in commit message: > > and there no clear winner. -> and there is no clear winner.  > > and it seem wasteful -> and it seems wasteful > > The there may be -> There may be > Thanks, will fix. > +       /* skip statistics with mismatching stxdinherit value */ > +       if (stat->inherit != rte->inh) > > Should a log be added for the above case ? > Why should we log this? It's an entirely expected case - there's a mismatch between inheritance for the relation and statistics, simply skipping it is the right thing to do. > +                    * Determine if we'redealing with inheritance tree. > > There should be a space between re and dealing. > Thanks, will fix. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company