public inbox for [email protected]  
help / color / mirror / Atom feed
From: sud <[email protected]>
To: Ron Johnson <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Dropping column from big table
Date: Thu, 11 Jul 2024 13:10:57 +0530
Message-ID: <CAD=mzVXK+4tLMbENMecruPbk8cmeE4smD=ENUrwx5wh4N7hZhA@mail.gmail.com> (raw)
In-Reply-To: <CANzqJaBAOzCjXaBFLa6cYweVNf5LbBvLYFkWx_hb3YezOP3quw@mail.gmail.com>
References: <CAD=mzVUGj2Zg0RY9YJwgDzAeghPjuT0FOnNs-aysTBGss87Yyw@mail.gmail.com>
	<[email protected]>
	<CAD=mzVUS8mFK42zmVUUC3JkiN=9QSUZ_Qxayd6=KJwbqdd0HzA@mail.gmail.com>
	<CANzqJaBAOzCjXaBFLa6cYweVNf5LbBvLYFkWx_hb3YezOP3quw@mail.gmail.com>

On Thu, 11 Jul, 2024, 12:46 pm Ron Johnson, <[email protected]> wrote:

> On Wed, Jul 10, 2024 at 11:28 PM sud <[email protected]> wrote:
>
>>
>>
>>
>> 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
>>
>
> "Impact" is a non-specific word.  "How much impact" depends on how many
> autovacuum workers you've set it to use, and how many threads you set in
> vacuumdb.
>
>
>> and blocking others?
>>
>
> VACUUM never blocks.
>
> 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).
>
> I'd detach all the partitions from the parent table, and then add the new
> column to the not-children in multiple threads, add the column to the
> parent and then reattach all of the children.  That's the fastest method,
> though takes some time to set up.
>


Thank you so much.

Dropping will take it's own time for post vacuum however as you rightly
said, it won't be blocking which should be fine.

In regards to add column, Detaching all partitions then adding column  to
the individual partition in multiple sessions and then reattaching looks to
be a really awesome idea to make it faster. However one doubt, Will it
create issue if there already exists foreign key on this partition table or
say it's the parent to other child partition/nonpartition tables?


view thread (4+ 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: <CAD=mzVXK+4tLMbENMecruPbk8cmeE4smD=ENUrwx5wh4N7hZhA@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