From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: Determine potential change in table size after a column dropped?
Date: Sat, 22 Jan 2022 07:38:26 -0600
Message-ID: <c9297bfb-409b-d1b9-9aba-e3c3491068e5@gmail.com> (raw)
In-Reply-To: <CAM+6J96mtviadpmVVN+GuVkrOYM7UQ=A+p6Frs7xz9pGusYkyA@mail.gmail.com>
References: <CAOC+FBWMDP4DOPEYMZH6ZS6EzKV8_twSSebGwD2eLUcEK+i4yg@mail.gmail.com>
<CAM+6J96mtviadpmVVN+GuVkrOYM7UQ=A+p6Frs7xz9pGusYkyA@mail.gmail.com>
On 1/22/22 1:43 AM, Vijaykumar Jain wrote:
>
>
> On Sat, Jan 22, 2022, 12:47 PM Wells Oliver <wells.oliver@gmail.com
> <mailto:wells.oliver@gmail.com>> wrote:
>
> I have a large large large table with many many many rows, and it's a
> certain size in pg_relation_size -- there's a timestamp with tz column
> on this table that's mostly kind of useless, and I want to figure out
> how much space it would free if we just dropped it. Can I easily do this?
>
>
> https://www.postgresql.org/docs/current/sql-altertable.html
> <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.
What about VACUUM FULL?
--
Angular momentum makes the world go 'round.
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: pgsql-admin@postgresql.org
Cc: ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
Subject: Re: Determine potential change in table size after a column dropped?
In-Reply-To: <c9297bfb-409b-d1b9-9aba-e3c3491068e5@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox