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 1mwXFk-0005aQ-Cx for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Dec 2021 22:23:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mwXFi-0007ei-T7 for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Dec 2021 22:23:30 +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 1mwXFh-0007eX-RD for pgsql-hackers@lists.postgresql.org; Sun, 12 Dec 2021 22:23:30 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mwXFc-0005Fp-At for pgsql-hackers@postgresql.org; Sun, 12 Dec 2021 22:23:28 +0000 Received: by mail-ed1-x536.google.com with SMTP id e3so47146648edu.4 for ; Sun, 12 Dec 2021 14:23:24 -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=JiAPia+37ro4IlwdhQcJrSvp8FntqJn17m1P57cUcxo=; b=VIiTs2uVbXKZC8b284Yw9cohiVzWHktJwsY37L09OBAzdfTjV2RtqAM0Z8KuqmV328 kINKIWf/eV/eOcQkdJNtI5KLGXcM3MisIC10+hbwN5QsKyL9C6fDoTYQZjSa6PD0X3f3 IBaLzal636WxoAEfxsz2w5YlvCF0ucyTu4bQj1x8jdMFsPh8q84NL34ZgCG4/6umHaXc Tw1JhzC0a5qEfqz9EEvXiu8TpASld8sPRBzREWevVniE1hcnb1WxH2M+/Fev06/wOf2t th1K0kk13nEXlH+wo9UB3Etlk83eYqF01qVHtURlHNekYTIm0+B/QNXm1qJw0aTXxwE2 /lEA== 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=JiAPia+37ro4IlwdhQcJrSvp8FntqJn17m1P57cUcxo=; b=x0Hk43O9Nr02o7o/VnX7wne2sFZze+Vus93EB6yBF2i1Izg06p/oYC0VMkRnWpEv40 nfoa9mnRjAWKonjySGA9SM55JudgONuDhke62hDbsh2YCHGj2P7hTSL3d1R6V27nct8h cybeg9BFsJ7JlGUqRjTVsomjYBq+1lqhbTAT1rmn85snDP9CjkUN86m5vOdNs17Si50a KCxTNDa6LvwFXsJoGsvkI1MYZFg/MGhzSvgrQdxzJBH/Y0qKMTHQX2Yl5qEf81xfZUbg EJ/6l2KFz2z12RYIh67Ui1F8kWWg9i/wmU85RqXfjzcCkqfk5NS2Q1gnS1Lm49GcQyGf lWjA== X-Gm-Message-State: AOAM530XahuSn1pACzaCkHw/CoRRQL0tXFOxoW6EQflx7o1Vy42mWEXt GelUJJ1cQE8l2bKGbuIXdxTtHZjD5ffGBBNo0MR35e7P3zig90Gze/Zc4Ha75BE+SNBF8RvYaMs yBPkdBXlsAjrOJfwSGi/QnMeaLWrS4aSsTB3pQA3maC9hjjPb6ltiC5mnp5Orl54j6MhjD5715t bmaBzs4hfslFtFNtvW1gVpl8oosEqqDFBjIHt9tjFnu5Cz X-Google-Smtp-Source: ABdhPJwTG+6I8/jxhexmPPvnpS4TOb2zPz3aNsw91BsfowtJY0cipz6P//N7hi6LZuoQ71Hor1cqpw== X-Received: by 2002:a50:da48:: with SMTP id a8mr57856896edk.146.1639347802114; Sun, 12 Dec 2021 14:23:22 -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 m6sm5165814edc.36.2021.12.12.14.23.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Dec 2021 14:23:21 -0800 (PST) Message-ID: Date: Sun, 12 Dec 2021 23:23:19 +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: Justin Pryzby Cc: Zhihong Yu , Jaime Casanova , pgsql-hackers@postgresql.org References: <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> <20211212213210.GP17618@telsasoft.com> From: Tomas Vondra In-Reply-To: <20211212213210.GP17618@telsasoft.com> Content-Type: text/plain; charset=UTF-8; format=flowed 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 12/12/21 22:32, Justin Pryzby wrote: > On Sun, Dec 12, 2021 at 05:17:10AM +0100, Tomas Vondra wrote: >> 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. > > You mean because the quals are pushed down to the scan node. > > Does that indicate a deficiency ? > > If extended stats are collected for a parent table, selectivity estimates based > from the parent would be better; but instead we use uncorrected column > estimates from the child tables. > > From what I see, we could come up with a way to avoid the pushdown, involving > volatile functions/foreign tables/RLS/window functions/SRF/wholerow vars/etc. > > But would it be better if extended stats objects on partitioned tables were to > collect stats for both parent AND CHILD ? I'm not sure. Maybe that's the > wrong solution, but maybe we should still document that extended stats on > (empty) parent tables are often themselves not used/useful for selectivity > estimates, and the user should instead (or in addition) create stats on child > tables. > > Or, maybe if there's no extended stats on the child tables, stats on the parent > table should be consulted ? > Maybe, but that seems like a mostly separate improvement. At this point I'm interested only in testing the behavior implemented in the current patches. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company