Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h6IBP-000685-8e for pgsql-admin@arkaria.postgresql.org; Tue, 19 Mar 2019 17:05:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h6IBN-0005aM-KL for pgsql-admin@arkaria.postgresql.org; Tue, 19 Mar 2019 17:05:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h6I8F-00045F-NE for pgsql-admin@lists.postgresql.org; Tue, 19 Mar 2019 17:02:31 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h6I8D-00025q-5i for pgsql-admin@lists.postgresql.org; Tue, 19 Mar 2019 17:02:31 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 9DEF2A34DA; Tue, 19 Mar 2019 18:02:27 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id w6kX0tDd2jyY; Tue, 19 Mar 2019 18:02:20 +0100 (CET) Message-ID: <6fff7b00a759e89f6468757602ac752c8d4ffdfc.camel@cybertec.at> Subject: Re: Adding Column on Huge Table From: Laurenz Albe To: Moin Akther , "pgsql-admin@lists.postgresql.org" Date: Tue, 19 Mar 2019 18:02:19 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Moin Akther wrote: > We want to add a column on table size of 1.5TB, we have to perform this activity with minimal downtime. > > What are the best practises to add a column on huge table ? > > How much time alter statement will take to add column ? > > Any alternate solution other than alter statement to add column ? > > Will adding a new column on a huge table generate huge WAL files ? As a quick experiment would have told you, adding a column without a DEFAULT clause is very fast. Since v11, it is fast even if the new column has a DEFAULT clause. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com