Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1grPgk-0006wo-4k for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Feb 2019 16:04:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1grPgi-0001iL-T4 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Feb 2019 16:04:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1grPgi-0001iE-Ly for pgsql-hackers@lists.postgresql.org; Wed, 06 Feb 2019 16:04:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1grPgg-0003GH-1b for pgsql-hackers@lists.postgresql.org; Wed, 06 Feb 2019 16:04:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x16G4Q1g026162; Wed, 6 Feb 2019 11:04:26 -0500 From: Tom Lane To: Alvaro Herrera cc: Andres Freund , pgsql-hackers@lists.postgresql.org Subject: Re: Refactoring IndexPath representation of index conditions In-reply-to: <20190206013512.GA3101@alvherre.pgsql> References: <20190206013512.GA3101@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Tue, 05 Feb 2019 22:35:12 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26160.1549469066.1@sss.pgh.pa.us> Date: Wed, 06 Feb 2019 11:04:26 -0500 Message-ID: <26161.1549469066@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2019-Feb-02, Tom Lane wrote: >> Another idea that I looked into is to not create RestrictInfos for >> derived indexqual clauses, with the hope that that would further >> reduce the added overhead for the commuted-clause case. However >> that crashed and burned when I found out that the extended-stats >> machinery punts when given a bare clause rather than a RestrictInfo. >> It could possibly be fixed to not do that, but it looks like the >> consequences would be extra lookups that'd probably cost more than >> we saved by omitting the RestrictInfo. Also, having RestrictInfos >> means that we can cache selectivity estimates across multiple >> calls. I'm not entirely sure how much that matters in this >> context, but it's probably not negligible. > Is it reasonable to give ext-stats the option to receive either a > "plain" clause or a RestrictInfo, and if the former have it construct > the RestrictInfo and return it? No, I don't think it'd be sane to have ext-stats modify that data structure after-the-fact. Too much risk of trouble (he says while eyeing the GEQO machinery warily); plus, if we did it like that, we'd *definitely* be giving up the ability to cache and share cost/selectivity numbers between ext-stats and other places. > It seems a pity to waste effort to > cater for ext-stats, only to be used in the rare case where any > ext-stats actually exist ... most of the time, it'd be wasted effort. I'm not sure it's a good idea to design on the assumption that ext-stats are rare. I think they'll get more common over time. Right now that machinery is hardly built out at all, but it's coming. regards, tom lane