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 1u298F-00Dj5U-Od for pgsql-committers@arkaria.postgresql.org; Tue, 08 Apr 2025 13:36:51 +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 1u298E-008mSX-6v for pgsql-committers@arkaria.postgresql.org; Tue, 08 Apr 2025 13:36:50 +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 1u298D-008mSA-Vt for pgsql-committers@lists.postgresql.org; Tue, 08 Apr 2025 13:36:50 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u298C-003gLL-1z for pgsql-committers@lists.postgresql.org; Tue, 08 Apr 2025 13:36:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2025010100; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=6dJ7lcPiEnv1mfDiKsblcqrIhznuebC1cPL1oykLlTU=; b=kHo0j 2sJWliPSxG5kTLxspUielEWc0G0N4UMm+ygDd3YpjC2R/LSIg4kbd7pOJUa2DeqaxW/350HUjes/X PIlMwJdAJI3HBSoWjDZZtgENLUv/aPXVlCxYWD2JLJio9afWJ0C2kQ1behov+u0g+piI8GG3w9gxL 0ZwLoM/mP3ze/sZATBO30YJH4bHEZdHUtr7FBi0gM7HTT0cYdbttHy183IHRZEYbYFkv0Mcxgk/JY WywRqOo63hoRoqlI8yG0yJYZ57BAr3xFLpiTyrhQxKqHWjf/7AycUN9wi2hBTTOr5RtbtlGyrIF0t ysYZJzOPy4ZbQQleiWfPPEg+yWLjQ==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1u298B-0026PP-2K; Tue, 08 Apr 2025 09:36:47 -0400 Date: Tue, 8 Apr 2025 09:36:47 -0400 From: Bruce Momjian To: pgsql-committers@lists.postgresql.org Cc: Tom Lane Subject: Re: pgsql: Fix PG 17 [NOT] NULL optimization bug for domains Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Apr 8, 2025 at 01:34:07AM +0000, Bruce Momjian wrote: > Fix PG 17 [NOT] NULL optimization bug for domains > > A PG 17 optimization allowed columns with NOT NULL constraints to skip > table scans for IS NULL queries, and to skip IS NOT NULL checks for IS > NOT NULL queries. This didn't work for domain types, since domain types > don't follow the IS NULL/IS NOT NULL constraint logic. To fix, disable > this optimization for domains for PG 17+. > > Discussion: https://postgr.es/m/Z37p0paENWWUarj-@momjian.us Ugh, I knew there was something odd about the commit message I wrote above, but I couldn't put my figure on it until this morning. The problem above is not "domains" but row types; the bug report showed it as an issue with row types used for domains, but it can happen with columns which are row types too. The doc adjustment was for domains, and that confused me. Tom, can you remember this in the 17.5 release notes? Thanks. The commit should have been: Fix PG 17 [NOT] NULL optimization bug for row types A PG 17 optimization allowed columns with NOT NULL constraints to skip table scans for IS NULL queries, and to skip IS NOT NULL checks for IS NOT NULL queries. This didn't work for row types, since row types don't follow the IS NULL/IS NOT NULL constraint logic. To fix, disable this optimization for row types for PG 17+. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Do not let urgent matters crowd out time for investment in the future.