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 1swi2p-005b5d-Qv for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Oct 2024 13:08: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 1swi2n-00GmY3-Mb for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Oct 2024 13:08:29 +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 1swi2m-00GmXu-WB for pgsql-hackers@lists.postgresql.org; Fri, 04 Oct 2024 13:08:29 +0000 Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1swi2d-002Vg6-Ce for pgsql-hackers@lists.postgresql.org; Fri, 04 Oct 2024 13:08:27 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id 3EDA713801F4; Fri, 4 Oct 2024 09:08:18 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 04 Oct 2024 09:08:18 -0400 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=fm2; t=1728047298; x= 1728133698; bh=eX9hiVaGZ3MharaV63R5SNM05ugw82CtXab9nXV56Ik=; b=G IEZmpkZNL8Mkn6emzsIlKWikD9IQiTUtJT1lyNARbaxUf7sqoYivGvxHK7GsIQAU OT+zoJ7LGMv4s1RAD3yQwsSssYR3c4q0VuvDISoMRMY+0ZB2Mf3ZJdGyAEqiwnvu yEAUxIqhoHwSlMms6WBb10QSAziArSNXUVXyrtjDtQzTM9b09mOpjOnG5Mawq+YF 7P+jn0E0z6cO+QQ8UX5SRQEzIo8M55hSHau4T9zEqKo2z+slbt5gNiMndNKbZV2W Ftec0VFgf1cuKE3h/cyQ/L9a3Qkcdyue5/gHMDXIw3AMTfqBVBpfH/p1mLfncsvP k/jRdkaelSdX+wCyJgSmw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddvfedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeen ucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhh drnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepheetudeftdehveeifeefvdet heetkedvvedvffeitefhkedutdfhheffiedtkedvnecuffhomhgrihhnpehgihhthhhusg drtghomhdpvghnthgvrhhprhhishgvuggsrdgtohhmpdhprghulhhgrhgrhhgrmhdrtgho mhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlh hvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsggprhgtphhtthhopeefpdhm ohguvgepshhmthhpohhuthdprhgtphhtthhopehjihgrnhdruhhnihhvvghrshgrlhhith ihsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhnughrfigrnhhgsehgmhgrihhlrdgt ohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtgh hrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Oct 2024 09:08:17 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1728047295; bh=vmg6Sp6R9vm3zvR6pTMq9dmdGQdWZHxmhfAWtreDjdM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=TMb8Ws5b3UgVEQTNoBZSlrWPItLHPEUj1vxRnGAwFkqO1o0MYZCVCTZbuSxQOBrQM bAABCDrdBjUoAuqa9Q5HGPqNoaLsC2nJ2h8lvF+9RLcG9guz7n113jGRxpmczgKru2 J79D96sCGowJrC6inERTqkNfKO5UDmPqUnSif7zRqTrPHkqGnJO2m6G5dUv+kxmYmg AaktQ1hYW8bCG7FvZ1Z+t9yV8b7Ib3tQ1JiVE4MpZSK15uPSb0I2i7cVRy1HnthhU0 yogNfHoBuanBvW4QzM7EiZcaOO0e/ou5zpW3DVRawnxboOfT/GBkV8DcCsBx42Epmt 98Ka+itZDn1fA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 29CC1AB; Fri, 4 Oct 2024 15:08:15 +0200 (CEST) Date: Fri, 4 Oct 2024 15:08:15 +0200 From: Alvaro Herrera To: jian he Cc: Tender Wang , Pg Hackers Subject: Re: not null constraints, again Message-ID: <202410041308.umwqeozh2zir@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-Oct-03, jian he wrote: > I thought SearchSysCacheCopyAttNum is expensive. > Relation->rd_att is enough for checking attnotnull. > > What do you think of the following refactoring of set_attnotnull? Eh, sure, why not. I mean, I expect that this is going to be barely noticeable performance-wise, but I don't see a reason not to do it this way. The new code in transformIndexConstraint() I added to verify NO INHERIT for columns in the PK[1] is likely to have a more noticeable impact: we have to scan the whole cxt->nnconstraints list for each column of the PK, and strcmp() the column names in order to find matches. I expect this this to be slow (and affect everybody) but I don't see any other reasonable way to do it. A possibility is to add a Constraint member to ColumnDef, and pre-process so that we attach the correct constraint definition to each column definition before invoking transformIndexConstraints in transformCreateStmt; we already do the match there, so it would be a good place for that. Alternatively, turn is_not_null into a tristate (yes, no, "yes but is no inherit"). [1] https://github.com/alvherre/postgres/commit/22e5820e241c744fb36cbc643a4d8d94162c562e -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "The problem with the facetime model is not just that it's demoralizing, but that the people pretending to work interrupt the ones actually working." -- Paul Graham, http://www.paulgraham.com/opensource.html