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 1pQ8Yu-00058B-Iu for pgsql-performance@arkaria.postgresql.org; Thu, 09 Feb 2023 15:10:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pQ8Yt-0007Bg-BB for pgsql-performance@arkaria.postgresql.org; Thu, 09 Feb 2023 15:10:11 +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 1pQ8Yt-00076t-1T for pgsql-performance@lists.postgresql.org; Thu, 09 Feb 2023 15:10:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQ8Ym-0003Gn-L1 for pgsql-performance@lists.postgresql.org; Thu, 09 Feb 2023 15:10:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 319FA1WM3893891; Thu, 9 Feb 2023 10:10:01 -0500 From: Tom Lane To: Mark Hills cc: Laurenz Albe , pgsql-performance@lists.postgresql.org Subject: Re: Domain check taking place unnecessarily? In-reply-to: <2302091035450.14632@stax.localdomain> References: <2302081605290.5352@stax.localdomain> <4b1a0c9e36280b1d4abeb4fb6336832409df6ae0.camel@cybertec.at> <2302091035450.14632@stax.localdomain> Comments: In-reply-to Mark Hills message dated "Thu, 09 Feb 2023 10:56:35 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3893889.1675955401.1@sss.pgh.pa.us> Date: Thu, 09 Feb 2023 10:10:01 -0500 Message-ID: <3893890.1675955401@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. regards, tom lane