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 1nw2sP-0003AB-4m for pgsql-general@arkaria.postgresql.org; Tue, 31 May 2022 14:29:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nw2sN-0004cz-Nn for pgsql-general@arkaria.postgresql.org; Tue, 31 May 2022 14:29:39 +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 1nw2sN-0004cq-DP for pgsql-general@lists.postgresql.org; Tue, 31 May 2022 14:29:39 +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 1nw2sL-00084d-7o for pgsql-general@postgresql.org; Tue, 31 May 2022 14:29:38 +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 24VETZmk173502; Tue, 31 May 2022 10:29:35 -0400 From: Tom Lane To: Danny Shemesh cc: pgsql-general@postgresql.org Subject: Re: The use of partial, expressional indices in pg < 14 In-reply-to: References: Comments: In-reply-to Danny Shemesh message dated "Tue, 31 May 2022 13:33:23 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <173500.1654007375.1@sss.pgh.pa.us> Date: Tue, 31 May 2022 10:29:35 -0400 Message-ID: <173501.1654007375@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Danny Shemesh writes: > 2. Would it be theoretically possible to use the collected statistics if > the index where clause is also specified in the query itself ? > or in other words, if the index only contains records where x is not null, > and the query also filters on x is not null, would the partial distribution > not be safe to use ? The hard part is to avoid double-counting the selectivity of the "is not null" clause if you do that. It's something that would be nice to do but it's much trickier than it sounds. regards, tom lane