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 1mOkkp-0005le-Gp for pgsql-general@arkaria.postgresql.org; Fri, 10 Sep 2021 17:55:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mOkko-0008C8-EN for pgsql-general@arkaria.postgresql.org; Fri, 10 Sep 2021 17:55:58 +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 1mOkko-0008Bz-3N for pgsql-general@lists.postgresql.org; Fri, 10 Sep 2021 17:55:58 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mOkkl-00072Z-OO for pgsql-general@postgresql.org; Fri, 10 Sep 2021 17:55:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Reply-To:Message-ID:Subject:Cc:To:Sender:From:Date: 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=qJBItZJIy2h7ATUsAU5od3Xsiip+qOOhfu+y6I5iDJk=; b=DEl5nalJhaZ62xsbGHpEPwlTA7 kVSlD9Xcq4n1YTB45zIVBkaUTumsJW+j6Gu/aFdAQ1SxlV8Tn7WM+FidrRN88H3IwWG2XDxoL5l7x SYIQWskt87TLTSLHD3bCNGCuaS44nh9xSA3jo2plaQs+v0XDFdLTAygut+qVLs8u+jvo=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.92) (envelope-from ) id 1mOkkj-00027o-3P; Fri, 10 Sep 2021 19:55:53 +0200 Date: Fri, 10 Sep 2021 19:55:52 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Gus Spier Cc: Alexander Kukushkin , pgsql-general mailing list Subject: Re: Is there any technical reason why "alter table .. set not null" can't use index? Message-ID: <20210910175552.GA7127@depesz.com> Reply-To: depesz@depesz.com References: <20210908051453.GB20274@depesz.com> <7E44EA26-9343-444F-B01C-30944AB8C60A@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7E44EA26-9343-444F-B01C-30944AB8C60A@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Sep 10, 2021 at 01:26:46PM -0400, Gus Spier wrote: > Would it help to create a new not null column in the target table, and > then update the table by copying values from old column to the new, > not null column? Of course you’d have to ignore errors, etc. but > wouldn’t that perform at enough for your needs? Why would you think that adding new column, with constraint, and copying data would be faster? depesz