public inbox for [email protected]
help / color / mirror / Atom feedFrom: sud <[email protected]>
To: Adrian Klaver <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Dropping column from big table
Date: Thu, 11 Jul 2024 08:58:18 +0530
Message-ID: <CAD=mzVUS8mFK42zmVUUC3JkiN=9QSUZ_Qxayd6=KJwbqdd0HzA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAD=mzVUGj2Zg0RY9YJwgDzAeghPjuT0FOnNs-aysTBGss87Yyw@mail.gmail.com>
<[email protected]>
On Thu, Jul 11, 2024 at 2:52 AM Adrian Klaver <[email protected]>
wrote:
>
> 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.
> "
>
>
Thank you so much. When you said *"you can execute one of the forms of
ALTER TABLE that performs a rewrite*
*of the whole table."* Does it mean that post "alter table drop column" the
vacuum is going to run longer as it will try to clean up all the rows and
recreate the new rows? But then how can this be avoidable or made better
without impacting the system performance and blocking others?
view thread (3+ messages)
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: <CAD=mzVUS8mFK42zmVUUC3JkiN=9QSUZ_Qxayd6=KJwbqdd0HzA@mail.gmail.com>
* 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