Re: Dropping column from big table

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Dropping column from big table
Date: 2024-07-11 13:05:09
Message-ID: 202407111305.swxs3no6pmhy@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2024-Jul-11, Ron Johnson wrote:

> Anyway, DROP is the easy part; it's ADD COLUMN that can take a lot of time
> (depending on whether or not you populate the column with a default value).

Actually, ADD COLUMN with a default does not rewrite the entire table
either, starting from pg11.

"Major enhancements in PostgreSQL 11 include:
[...]
* Many other useful performance improvements, including the ability to
avoid a table rewrite for ALTER TABLE ... ADD COLUMN with a non-null
column default."

https://www.postgresql.org/docs/11/release-11.html

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dimitrios Apostolou 2024-07-11 14:08:42 Re: Query on partitioned table needs memory n_partitions * work_mem
Previous Message Ron Johnson 2024-07-11 12:36:32 Re: Dropping column from big table