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 1rSMFU-00DFnA-Oi for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jan 2024 19:15:53 +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 1rSMFT-00FUng-0v for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jan 2024 19:15:51 +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 1rSMFS-00FUnY-Cw for pgsql-hackers@lists.postgresql.org; Tue, 23 Jan 2024 19:15:50 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSMFL-003LVS-7C for pgsql-hackers@lists.postgresql.org; Tue, 23 Jan 2024 19:15:49 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id DEE6C5C0143; Tue, 23 Jan 2024 14:15:40 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 23 Jan 2024 14:15:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1706037340; x= 1706123740; bh=ddAt8kW/dc+zxfnF4oPN6dF6UqRrFrjN08mEXHoKdNM=; b=C kqzlvtBfqTnk1Ab78P6BxAmSRL/PpEAVnYt6If1oucdsZCkHWJ7cjQ23NoklhjmI 9SMpZK07ihCvH+9ZxCO3z0UEApIfr4GMfsreHNx8Xl+t457RqUnBu4WaoIDLJipY 3FQwucuH9D0qZXqBxFB0Xs2kpWeTmeHHy+rgOW4PDmMXaXgeIuGQ3075wULc9PC9 FyyvxXpI72dEYzt1H9QywzbZTbYsbUr12ZN1QuQ5Rb5chMsdjFkqWZMFkFHEgHqZ y+wONFRz3BOw0mfqY+x90fnZt5uhZW+5p941BE1EdhiMGOtbNTTDCRPpVV3bupy5 Hhhv8yiYYVn4BK/ysAZdg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdekkedguddvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhv rghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hgqeenucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeej keffgfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtoh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghl vhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 23 Jan 2024 14:15:40 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1706037338; bh=l4orGAVAhJeKVSgjmgcp4nCthn7FLXHrNl7xAWmNmIU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=AtEC3IhHxGAXbGaiDRO6+WzL6VrC8/WBi5appUPCLXd/xuXGZJ2Nzt0NJQaYFC8Wm GuWHVb9rgXMzUJnHVZJHVTZzvGoyxq7woFHvZU6m41j0tshWxmehNQeIlsGw9n/Qo0 VS5lChMtYS0X3ivbXRco9oOWjZTz0FKX1x/agk27Gdj2wp8DTbk1mSyj3nm6BO7os9 d5sUAs8V4KfZAr73Oh1H+DrtblCLF6E7ht0iD4dtS/PPVuy/mJILRQ8PX4COo2srBL JjrzZizKkJoPNcXYGg5izyNF2Ddj6FX8rFYUs1K16ODug6hXhmW0n92qSnoUahR7mM iWgxKL3Rg3v3Q== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id D8ED298; Tue, 23 Jan 2024 20:15:38 +0100 (CET) Date: Tue, 23 Jan 2024 20:15:38 +0100 From: Alvaro Herrera To: David Rowley Cc: pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Add better handling of redundant IS [NOT] NULL quals Message-ID: <202401231915.uwk6zrqbdvsu@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Jan-23, David Rowley wrote: > Add better handling of redundant IS [NOT] NULL quals > > 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. One of the motivations for adding catalogued NOT NULL constraints was precisely to have an OID that you could use to cause plancache to invalidate such a plan. Does this new code add something like that? Admittedly I didn't read the threads or the patch, just skimmed for some clues, so I may have failed to notice it. But in the tests you added I don't see any ALTER TABLE DROP CONSTRAINT. (Similarly, allowing GROUP BY to ignore columns not in the GROUP BY, when a UNIQUE constraint exists and all columns are NOT NULL; currently we allow that for PRIMARY KEY, but if you have the NOT NULL constraint OIDs to cue the plan invalidation would let that case to be implemented as well.) -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Por suerte hoy explotó el califont porque si no me habría muerto de aburrido" (Papelucho)