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 1pQQyI-0005DU-IE for pgsql-performance@arkaria.postgresql.org; Fri, 10 Feb 2023 10:49:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pQQyG-0003Zy-J2 for pgsql-performance@arkaria.postgresql.org; Fri, 10 Feb 2023 10:49:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQQyG-0003TV-1z for pgsql-performance@lists.postgresql.org; Fri, 10 Feb 2023 10:49:36 +0000 Received: from disco.pogo.org.uk ([93.93.128.62]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQQyB-0001tu-VZ for pgsql-performance@lists.postgresql.org; Fri, 10 Feb 2023 10:49:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xwax.org; s=swing; h=Content-Type:MIME-Version:References:Message-ID:In-Reply-To: Subject:cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lkQIPX9B8pLqMRpH/uLn+C4GHHBKPvje33JPnMLen5c=; b=PoEnr4QSafSfQ7c4Ll2cP8htbT nwxR63UItuGfXSlr1Lzf6YWPInDhagH75GciyGnZRQw3CMWaBXAViN/W0LoeYw9jdvtzU8MvKDEUM u7+7aJGa3xovUzbh9bHXxnGAobZYDxVhxot0w2GWwDlq4VVME9V2iulEmK3aMBO0CBFk=; Received: from cpc93788-hari17-2-0-cust1237.20-2.cable.virginm.net ([82.39.100.214] helo=stax) by disco.pogo.org.uk with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95 (FreeBSD)) (envelope-from ) id 1pQQy0-0004Fp-QK; Fri, 10 Feb 2023 10:49:29 +0000 Received: from localhost (stax.localdomain [local]) by stax.localdomain (OpenSMTPD) with ESMTPA id 9cd14c52; Fri, 10 Feb 2023 10:49:25 +0000 (UTC) Date: Fri, 10 Feb 2023 10:49:25 +0000 (GMT) From: Mark Hills To: Tom Lane , Laurenz Albe cc: pgsql-performance@lists.postgresql.org Subject: Re: Domain check taking place unnecessarily? In-Reply-To: <3893890.1675955401@sss.pgh.pa.us> Message-ID: <2302101040520.20262@stax.localdomain> References: <2302081605290.5352@stax.localdomain> <4b1a0c9e36280b1d4abeb4fb6336832409df6ae0.camel@cybertec.at> <2302091035450.14632@stax.localdomain> <3893890.1675955401@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 9 Feb 2023, Tom Lane wrote: > Mark Hills writes: > > On Wed, 8 Feb 2023, Laurenz Albe wrote: > >> It takes 30 seconds to schan the table and determine that all existing > >> rows satisky the constraint. > > > But there's no existing data (note this is adding column, not constraint) > > > Existing rows are guaranteed to satisfy the domain check, because the > > domain check is guaranteed to be immutable (per [1] in my original mail) > > immutable != "will accept null". > > There could be some more optimizations here, perhaps, but there aren't. Well that's no problem at all. Thanks for the clarification. I mentioned this case to a few people and they were also surprised by the outcome, to the point where we wondered if this might be misbehaving. Hence bringing it up in this forum. We'll go ahead and deal with the pauses in production, as I don't think there's a workaround. Thanks -- Mark