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 1oaavT-0004rF-2N for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Sep 2022 10:56:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oaavR-0006OH-Tb for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Sep 2022 10:56:25 +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 1oaavR-0006O8-KR for pgsql-hackers@lists.postgresql.org; Tue, 20 Sep 2022 10:56:25 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaavP-0006AV-6S for pgsql-hackers@lists.postgresql.org; Tue, 20 Sep 2022 10:56:24 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 000A532009DD; Tue, 20 Sep 2022 06:56:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 20 Sep 2022 06:56:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1663671381; x=1663757781; bh=4 ezOBXLcd0zvbP127t2ip6eRV/ounWmaGwGQIm35mUo=; b=kmFNm7nWJo2WzM0J9 vFWwTHuTw/ivNIcaZ6GZdhHL44BvipkwT1ELmex/c5KUUvSsVyjkuxWg3P1+BarK FRvSVQjZ0wy/cIrgmhLFZxA0v2C0OyiVHhDEHtE8WWunLfdmmI+1v+AVmWA+1qES PyEF6b7ajrHXdY0fq4+3MQwD5yAr+n9HierLY43hnUTjcI7F+MVSWF263TLWQXDW r5ClrB723/xHGDeGBWTmuOJbRWvBT+NlaVb4YhlYc8FyUB6YPcQIZR8cqF9SCjnY X2EcE/24yNjnV0hxUazST2rtqiRNHMjtS8MAu3q+G4KqbbxFaDEbDVBn5yjglE2C eUVnQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvledgfeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Sep 2022 06:56:21 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 44B1638F; Tue, 20 Sep 2022 12:56:19 +0200 (CEST) Date: Tue, 20 Sep 2022 12:56:19 +0200 From: Alvaro Herrera To: Matthias van de Meent Cc: Robert Haas , Pg Hackers Subject: Re: cataloguing NOT NULL constraints Message-ID: <20220920105619.ofr2qmoyjnmmnsei@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 2022-Sep-19, Matthias van de Meent wrote: > I'm not sure on the 'good' part of this alternative, but we could go > with a single row-based IS NOT NULL to reduce such clutter, utilizing > the `ROW() IS NOT NULL` requirement of a row only matching IS NOT NULL > when all attributes are also IS NOT NULL: > > Check constraints: > "tab_notnull_check" CHECK (ROW(a, b, c, d, e) IS NOT NULL) There's no way to mark this NOT VALID individually or validate it afterwards, though. > But the performance of repeated row-casting would probably not be as > good as our current NULL checks The NULL checks would still be mostly done by the attnotnull checks internally, so there shouldn't be too much of a difference. .. though I'm now wondering if there's additional overhead from checking the constraint twice on each row: first the attnotnull bit, then the CHECK itself. Hmm. That's probably quite bad. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/