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 1vmEe1-009C5J-12 for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Jan 2026 17:20:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vmEdz-008qEY-1B for pgsql-hackers@arkaria.postgresql.org; Sat, 31 Jan 2026 17:20:24 +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.96) (envelope-from ) id 1vmEdy-008qEP-1b for pgsql-hackers@lists.postgresql.org; Sat, 31 Jan 2026 17:20:23 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vmEdw-00000000ONl-2oTZ for pgsql-hackers@lists.postgresql.org; Sat, 31 Jan 2026 17:20:23 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8E5F71400056; Sat, 31 Jan 2026 12:20:17 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Sat, 31 Jan 2026 12:20:17 -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=1769880017; x= 1769966417; bh=pFUsd8z3yD6WPbEupp/o65GfKjsb9xmgBO9xGq6PYxI=; b=u CyeCL2/djdlzf2gWDosFstKJoVG1JpMbecWZdbUvIgIXeu4BC2X4Cp7T1y88HidV oBcKtnHSRVT356jRvkWDLP6kCitWEEmkdG0npofeex1IHXvW27MYm5fprXkfRxAs GliW7SU6v0dZbijMXf0cLD1U6CpLfBc4ZKsIYnG6fpn5iJRvWMxz2VraKLgKMU0Q QZHg2DzznAGhnzStr8FLnbrgIGiDvbDqcehrj0aNblg4CICFjtHRLJVHgbvo8zdB QYiMlw+iXoxjj8WEdEn8KOo3SyPC6tfC/v2Pm0ICmA2jRFxON9I97CAer2bjI+RI iqsxKL687nvT1O36K9Kww== 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=fm3; t=1769880017; x=1769966417; bh=p FUsd8z3yD6WPbEupp/o65GfKjsb9xmgBO9xGq6PYxI=; b=J+3Z8LGFaesYDu8v2 cIUC+3jlDdh1cbWUNu+LVEz4D616NTxtcZjpPvCbeBcRpmLQT6noHCLqAdks0922 xD85fvyGeLX/LZZ6/gFAueSSIam2muRK1EwN7WPcr2l9TZS+95vhbP2E+RjyJjjM kGhMuWWDxQUVNlQ3x6n2ewo4Suu/gS+kx6TZ64Gj7P1WOxSBO1+XGSux2lUGvL31 6QrViQ7Bergc9Cq4MktlDoIgROFqLY31kKxScIJuQL5nkUb7a4Q8nTYMwM7trH8y 4DuMVBG8xb72+/iBBptvdZtA6i8XYzg9dasAXLDgQfN+q+/ai1IIaBnentA1eo9t lmEUQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddujedvhedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeetuedvheffkeevgfeuheevteevkefggedttdeufeeuheduuddthfef fffhjeefffenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgv sehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopehjihgrnhdruhhnihhvvghrshgrlhhithihsehgmhgrihhlrdgt ohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtgh hrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 31 Jan 2026 12:20:17 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1769880014; bh=gNLmAsdmcSTVHvwwzVROMt18RR53wIc8zo45fWUgack=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=rMZalQce2CKuzyp46JoT8AxqURX1tz1DmK2byW2egPqf0xRJZhWjxNKI1xlzVZiw7 ROxjaGVjpNgw26TPU6nHUzwjCpgE3KJgaGaHQ+ORNcfE2z8WvXuMZnqHZoXjpv4xnz TZSpa5qKbC91Q8IaTxLN+r5S/hjgP1cUd/SOWApuek2eZOcVHnjH6MYvq7HPzj0fQ5 TqCmGX1pumy+zBXG6HK0riMoViNnoeVw+dHU/kSNJCmM3Ja+Gd96t8KTUj9QUxM2BQ 1Ol1PaKNirsn0iOGNehxYGdrF4FgIo4I3cJVIrxWvoz3oJuKtxGjZJEXiNZIfCONIa PW59B9ZOoMYXA== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id 9AB2D74; Sat, 31 Jan 2026 18:20:14 +0100 (CET) Date: Sat, 31 Jan 2026 18:20:14 +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: <202601311716.jeczqdjsmh57@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 2026-Jan-16, jian he wrote: > In this case, scanning the t3_copy_idx index to check these four NOT NULL > constraints is actually slower than a full table scan. > > Therefore, I further restricted the use of the index-scan mechanism for fast NOT > NULL verification to scenarios where the attribute being checked is the leading > column of the index. Makes sense. > I have not yet addressed all of your other comments, as this > represents a more of a > major change. Therefore, I am submitting the attached patch first. OK, this means we're still waiting then. Please do see my v8 patch. It contained other cleanups as well. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "La gente vulgar sólo piensa en pasar el tiempo; el que tiene talento, en aprovecharlo"