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 1rSMbt-00DI96-4Y for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jan 2024 19:39:01 +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 1rSMbs-00FvI0-1o for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jan 2024 19:39:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSMbr-00FvHs-OV for pgsql-hackers@lists.postgresql.org; Tue, 23 Jan 2024 19:38:59 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSMbp-0030lp-Cl; Tue, 23 Jan 2024 19:38:58 +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 40NJcsZa4071563; Tue, 23 Jan 2024 14:38:54 -0500 From: Tom Lane To: Alvaro Herrera cc: David Rowley , pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Add better handling of redundant IS [NOT] NULL quals In-reply-to: <202401231915.uwk6zrqbdvsu@alvherre.pgsql> References: <202401231915.uwk6zrqbdvsu@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Tue, 23 Jan 2024 20:15:38 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4071561.1706038734.1@sss.pgh.pa.us> Date: Tue, 23 Jan 2024 14:38:54 -0500 Message-ID: <4071562.1706038734@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > On 2024-Jan-23, David Rowley wrote: >> Until now PostgreSQL has not been very smart about optimizing away IS >> NOT NULL base quals on columns defined as NOT NULL. > Hmm, what happens if a NOT NULL constraint is dropped and you have such > a plan in plancache? As I recall, lack of a mechanism to invalidate > such plans was the main reason for Postgres not to have this. IIRC, we realized that that concern was bogus. Removal of such constraints would cause pg_attribute.attnotnull to change, leading to a relcache invalidation on the table, forcing replan. If anyone tried to get rid of attnotnull or make it incompletely reliable, then we'd have problems; but AFAIK that's not being contemplated. regards, tom lane