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 1mUGDA-0001hG-7v for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Sep 2021 22:32:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mUGD7-0000U8-Tr for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Sep 2021 22:31:57 +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 1mUGD7-0000U0-Lr for pgsql-hackers@lists.postgresql.org; Sat, 25 Sep 2021 22:31:57 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mUGD4-0006qj-UF for pgsql-hackers@postgresql.org; Sat, 25 Sep 2021 22:31:56 +0000 Received: by mail-il1-x136.google.com with SMTP id b8so14537496ilh.12 for ; Sat, 25 Sep 2021 15:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Bo8XTJ6kAP7J+pxetrHy0Z5nhCOuA51yYrVayuXxgT8=; b=Qn8W17VD/ieG1ES9QmhCGms9FEPHSrW3Pu4XWe9dOtfdy6y8qNvHavsZKPVCE1gGrV hw9TALoBVZIqdmsVDcSsxrqgeNNWupwtunbmQAQHtnQlFrme1cI2BfWfQYbRc9czaN9H UhKQWQ/E08gtafNLAAtOacHHJe21iksD6jPq6G3XkvB24UXco98rjAhQ0lVQ5Ryxyu45 7pEJogt2nqvYUL+wUjJLb9dfn3yz3+tyR/XgM124sWEeDaXv/WN0zxnibn2PBQSrn5Fj trbEbkKtviAjNlc9YZe0nCB6PE0QjBdrn16RM+qqNmHlhDSdvbQr2Qpj6Bn7LEYSP4oL Jv2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Bo8XTJ6kAP7J+pxetrHy0Z5nhCOuA51yYrVayuXxgT8=; b=zIekgcpdVCBSwXmLOso6mzgFuaqhsgMLx3LWPBL8mAzz8CqN6fWvcyAtCCyeTAXJQM 3i6dBefWgn4OKKNNJkqaKzsYWggKU/0IJgg61ESjArCXXS2HE0vSytqdcW8OQRBIKE9n Mo+kas7CQgzBG+rMHQZ58surD3EAbBMtfo1ym/yzSW6b/UpdqvvoIu1+ruqiEVrafWdB QDzvfUjL6LLJ6/1QK+13vamnSWEGUPgJasLivD1lLx7zATAX47RuUVSfbKB/kVVa7k8J 1ou8R4vAbPP+A9Fp53upjGmBouk8cuR//Vzxq6S19qHy6mXJOLahhuEM9zZ0fp7scsjY E1Ig== X-Gm-Message-State: AOAM531ThJ78qFMFV3vV/4/+RCHho1FFmf0IcuuNJILebxZcEsfZHWTF YIfFb46dAVs09YOqB7XrDsxRHw== X-Google-Smtp-Source: ABdhPJx+XufrSkMTb375NLyy+jg/V+pWk0OEoyOz5cdul/Fn8Z64lbHw+J7Ekwu8ZI09SrMv0u2JkQ== X-Received: by 2002:a05:6e02:bc4:: with SMTP id c4mr13725120ilu.129.1632609113672; Sat, 25 Sep 2021 15:31:53 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f7sm6433295ilc.82.2021.09.25.15.31.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Sep 2021 15:31:53 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 4FE87800B38; Sat, 25 Sep 2021 17:31:52 -0500 (CDT) Date: Sat, 25 Sep 2021 17:31:52 -0500 From: Justin Pryzby To: Tomas Vondra Cc: pgsql-hackers@postgresql.org Subject: Re: extended stats on partitioned tables Message-ID: <20210925223152.GA7877@telsasoft.com> References: <20210923212624.GI831@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk (Resending with -hackers) It seems like your patch should also check "inh" in examine_variable and statext_expressions_load. Which leads to another issue in stable branches: ANALYZE builds only non-inherited stats, but they're incorrectly used for inherited queries - the rowcount estimate is worse on inheritence parents with extended stats than without. CREATE TABLE p(i int, j int); CREATE TABLE p1() INHERITS(p); INSERT INTO p SELECT a, a/10 FROM generate_series(1,9)a; INSERT INTO p1 SELECT a, a FROM generate_series(1,999)a; CREATE STATISTICS ps ON i,j FROM p; VACUUM ANALYZE p,p1; postgres=# explain analyze SELECT * FROM p GROUP BY 1,2; HashAggregate (cost=26.16..26.25 rows=9 width=8) (actual time=2.571..3.282 rows=1008 loops=1) postgres=# begin; DROP STATISTICS ps; explain analyze SELECT * FROM p GROUP BY 1,2; rollback; HashAggregate (cost=26.16..36.16 rows=1000 width=8) (actual time=2.167..2.872 rows=1008 loops=1) I guess examine_variable() should have corresponding logic to the hardcoded !inh in analyze.c. -- Justin