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.96) (envelope-from ) id 1vfiEg-004NcN-0K for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 17:31:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vfiEf-005waW-13 for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 17:31:17 +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.96) (envelope-from ) id 1vfiE6-005txu-2h for pgsql-hackers@lists.postgresql.org; Tue, 13 Jan 2026 17:30:43 +0000 Received: from fhigh-a3-smtp.messagingengine.com ([103.168.172.154]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vfiDt-000Euu-2j for pgsql-hackers@lists.postgresql.org; Tue, 13 Jan 2026 17:30:42 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id DAE6A14000D8; Tue, 13 Jan 2026 12:30:29 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Tue, 13 Jan 2026 12:30:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm1; t=1768325429; x= 1768411829; bh=khGP5O/3+Y4jC0mjETZMEffrFwQQ0NvlvhiQIfcKPdA=; b=c GzuMvL8SxxWNuWa3XFcyDweJBrA+jlvrER1lXeTI3MbD5/zWlSch6DNOX6O+fa1u VHUm9bzyBOj7KxES3uZvoge1FjxWWLk44/p33MFVeLWoX+Rdyvd15+9rsIeEvuZv nh43GGyUOHdlQvXw1p0eZe0KaW6paC5sPR44rLXdAm3msSWq4bDYx6NRcGCeZwmf v9Z0ZJgXm7M/cohm/I9FraYsjE1xFu4QrFO+KsqiNaaKYHUVjxpabOfP5ISnRlVX R3cQdp2WaE9QA65x2NNC7E5HyG7Orwt4GMsvKPbP2ytXXUd4aAASGw1WtWqRQRUK 6Y3q1pednBxyvbIQWsIhw== 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-sender :x-me-sender:x-sasl-enc; s=fm2; t=1768325429; x=1768411829; bh=k hGP5O/3+Y4jC0mjETZMEffrFwQQ0NvlvhiQIfcKPdA=; b=d6/9xQ76vuP6nf0Sk pSO1W82eE9palo7NHZd++/irFPmT8Rc74j2Oz4gYp5mmZfF1RRhjSac2xCqxPx9s l+rY38nz4x2mZqcvzzDmu6AhAzIHdWHbHbA+R9k+Hm8neJ3nctkoth7BtZsjP3p6 FmHb6V6O8H0gssCtMWUHegwe8Q+UKAS3RoFHNSO6tlnKZ/43jRzR8po+lS2FyOe+ Je/mh34VdGmc9ceTNop5vknVatohaWI5TlnLIsNBrINEIpdxeiz3crLHzhS8jmqg a6jlHHXG4zr2lbDGWpCNO8VZDDTjfRxoTTA8e8xQtRH0V8g+GCSdYcYyZhXwq2SY my/Yw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduvddtledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeegudetudejheduveevgeehjeegleevveevvdeutdejtdekuefhheeh geevtdejteenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgv sehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopehjihgrnhdruhhnihhvvghrshgrlhhithihsehgmhgrihhlrdgt ohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtgh hrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 13 Jan 2026 12:30:29 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1768325427; bh=m2tjL73DD1bHz/TzZWZG5QaXE4uAFRN5nSA6wVwd76Y=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=uelzr72qYcefil4u4Ff5Wp51yYW0gsBQJF69rh4ftLbIsYNkxOggDFD7yYSjG2aNE 3Omr0kUiDSt5AfCyy83U0ngLZADBmlpi6h2GsDACPUTX5wG1kQGMxnxIJlVotNoAfn wOBD8j11xGa83CGM5NycFbh4dX/8umDgVy3tHWAXvJj17iZI8murp0Fm1fR1IkFNoo 555Z+ntU4S3CjneJiVaIsBmB0vKVDh0gBawU6VLpAUbDUrdA1xnxyld/Mgt+Cw6OC1 WuFD0psJ74O5pwQRhbtn4cDO1ApAjDl1tz2i9oBKdu2VDl5rNiR8rAzmEIdgBazkLz O/m8dekbq3QYg== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id 71E517A; Tue, 13 Jan 2026 18:30:27 +0100 (CET) Date: Tue, 13 Jan 2026 18:30:27 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: jian he Cc: PostgreSQL Hackers Subject: Re: using index to speedup add not null constraints to a table Message-ID: <202601131715.cheonohttbyj@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xpkr6zhfzd3fjt76" 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 --xpkr6zhfzd3fjt76 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello I rebased this patch to review it. Overall, I think this is a great idea. Here are some comments on the patch, which I hope are not anything major. I'm not really sure that I agree with the way ATRewriteTable works now. It seems that we scan the list of columns, and verify each one for nulls, but abort midway if a column is generated. Surely we should check for generated columns first, to avoid wasting time verifying earlier columns in case a later column is generated? That said, we do check for notnull_virtual_attrs to be NIL. It seems to me that this implies that the checked columns are not generated. In other words, the test for whether columns are generated is unnecessary and confusing, and in which case you don't have to change anything, just remove the "if (attr->attgenerated == ATTRIBUTE_GENERATED_VIRTUAL)" inner block. However, if we do this, then I think computing notnull_attrs is pointless. So we should only change the order: do this new check first, and if we find that any new not-null column is on a generated column, then we compute both notnull_virtual_attrs and notnull_attrs. No? The separation of labor between index_check_notnull() and index_check_notnull_internal() seems a bit pointless. Why not have a single routine that does both things? Though, to be honest, it does look like the former should live in tablecmds.c instead of execIndexing.c. (But if you do split things that way, then you need to make index_check_notnull_internal extern). The tests look a bit excessive. Why do we need an isolation test for this? And it looks to me like the other test could be in src/test/regress rather than be a TAP test. After all, that's what you have the ereport(DEBUG1) there, isn't it? "veritify" doesn't exist. The word is "verify". -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ Syntax error: function hell() needs an argument. Please choose what hell you want to involve. --xpkr6zhfzd3fjt76 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v8-0001-using-indexscan-to-speedup-add-not-null-constrain.patch"