public inbox for [email protected]
help / color / mirror / Atom feedFrom: Adrian Klaver <[email protected]>
To: sud <[email protected]>
To: pgsql-general <[email protected]>
Subject: Re: Dropping column from big table
Date: Wed, 10 Jul 2024 14:22:40 -0700
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAD=mzVUGj2Zg0RY9YJwgDzAeghPjuT0FOnNs-aysTBGss87Yyw@mail.gmail.com>
References: <CAD=mzVUGj2Zg0RY9YJwgDzAeghPjuT0FOnNs-aysTBGss87Yyw@mail.gmail.com>
On 7/10/24 13:13, sud wrote:
> Hi All,
> It's postgres database version 15.4. We have a table which is daily and
> is approx. ~2TB in size having a total ~90 partitions. We have a
> requirement to drop columns and add new columns to this table.
>
> I Want to understand, If this can be done online? what is the fastest
> way to drop/add columns from such a big table and what will be the
> consequence of this in regards to vacuum, post this activity? Or if any
> other issues we may face post this?
>
> Regards
> Sud
https://www.postgresql.org/docs/current/sql-altertable.html
"The DROP COLUMN form does not physically remove the column, but simply
makes it invisible to SQL operations. Subsequent insert and update
operations in the table will store a null value for the column. Thus,
dropping a column is quick but it will not immediately reduce the
on-disk size of your table, as the space occupied by the dropped column
is not reclaimed. The space will be reclaimed over time as existing rows
are updated.
To force immediate reclamation of space occupied by a dropped column,
you can execute one of the forms of ALTER TABLE that performs a rewrite
of the whole table. This results in reconstructing each row with the
dropped column replaced by a null value.
"
--
Adrian Klaver
[email protected]
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Dropping column from big table
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox