Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1shHo4-00Fp1g-W1 for pgsql-performance@arkaria.postgresql.org; Fri, 23 Aug 2024 00:05:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1shHo2-0070I2-QY for pgsql-performance@arkaria.postgresql.org; Fri, 23 Aug 2024 00:05:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1shHo2-0070Hu-Fs for pgsql-performance@lists.postgresql.org; Fri, 23 Aug 2024 00:05:31 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1shHnz-0011uk-Dt for pgsql-performance@lists.postgresql.org; Fri, 23 Aug 2024 00:05:30 +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 47N05JbL2099117; Thu, 22 Aug 2024 20:05:19 -0400 From: Tom Lane To: Sbob cc: Rui DeSousa , "pgsql-performance@lists.postgresql.org" Subject: Re: checking for a NULL date in a partitioned table kills performance In-reply-to: References: <1c1a23bc-fa35-4a45-8017-62791506d91b@quadratum-braccas.com> Comments: In-reply-to Sbob message dated "Thu, 22 Aug 2024 17:32:18 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2099115.1724371519.1@sss.pgh.pa.us> Date: Thu, 22 Aug 2024 20:05:19 -0400 Message-ID: <2099116.1724371519@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sbob writes: > 29 million of the 32 million rows in the table have NULL for contract_date [ blink... ] So your query is selecting at least 29/32nds of the table, plus however much matches the contract_date > '2022-01-01' alternative. I'm not sure how you expect that to be significantly cheaper than scanning the whole table. regards, tom lane