pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alex Balashov <abalashov@evaristesys.com>
To: Devendra Yadav <devendra.857@gmail.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: ALTER TABLE ADD COLUMN takes forever
Date: Mon, 29 Mar 2021 13:11:48 -0400
Message-ID: <F22A024E-0D14-47DD-BF3A-3C11F5EE278D@evaristesys.com> (raw)
In-Reply-To: <CAE+tJY8xRe_PoYbBveOMRnm17wbtjCMMS8rdJfCdKjztymHbYQ@mail.gmail.com>
References: <CAE+tJY8xRe_PoYbBveOMRnm17wbtjCMMS8rdJfCdKjztymHbYQ@mail.gmail.com>

I know your pain well. It is because you set a default value for the column, so it has to initialise that value for every role. If you don’t set a default, it should be quite expedient, so you have to weigh that.

—
Sent from mobile, with due apologies for brevity and errors.

> On Mar 29, 2021, at 1:08 PM, Devendra Yadav <devendra.857@gmail.com> wrote:
> 
> 
> Hello Experts,
> 
> I am running a query on a table - ALTER TABLE mytable ADD COLUMN deposited DOUBLE PRECISION DEFAULT 0.0;
> 
> this query just runs forever. Few more details about this table -
> Total row count - 300000 (a small table of 200MB)
> Columns - 42
> Indexes - 15
> Foreign key constraint - 14
> Table reference - 11
> 
> When i check for the query in pg_stat_activity the wait even is LOCK and wait_event_type is RELATION. 
> Also when i check in pg_locks the granted status is 'f'. However there are no pid's blocking this transaction.
> 
> This has just 500 dead tuples, so no problems there as well
> 
> I am a DBA and not good at development. 
> Unable to understand what would be causing this? Could you guys help me what should be my next approach or solutions on this .
> 
> Regards,
> Devendra Yadav

view thread (7+ messages)  latest in thread

Message-ID: <F22A024E-0D14-47DD-BF3A-3C11F5EE278D@evaristesys.com>
Permalink:  ../F22A024E-0D14-47DD-BF3A-3C11F5EE278D@evaristesys.com/
Also on:    postgresql.org/message-id/F22A024E-0D14-47DD-BF3A-3C11F5EE278D@evaristesys.com

 · 

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: pgsql-admin@postgresql.org
  Cc: abalashov@evaristesys.com, devendra.857@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: ALTER TABLE ADD COLUMN takes forever
  In-Reply-To: <F22A024E-0D14-47DD-BF3A-3C11F5EE278D@evaristesys.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