From: Jaime Casanova <jcasanov@systemguards.com.ec>
To: Tomeh, Husam <HTomeh@facorelogic.com>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: Altering a column (increasing size) in Postgres takes long time
Date: Thu, 25 Feb 2010 18:40:55 -0500
Message-ID: <3073cc9b1002251540s8b91e7cw844b3bb6da2a0cd@mail.gmail.com> (raw)
In-Reply-To: <F1B0F9305B343E43A1C3EECE48B853D5056A1328@CITGSNA01SXCH02.ana.firstamdata.com>
References: <7965A9DCF12CC14984420BCC37B1608F25A9E2D038@Elzar.grant.co.uk>
<F1B0F9305B343E43A1C3EECE48B853D50501DD40@CITGSNA01SXCH02.ana.firstamdata.com>
<F1B0F9305B343E43A1C3EECE48B853D5056A1328@CITGSNA01SXCH02.ana.firstamdata.com>
On Thu, Feb 25, 2010 at 6:04 PM, Tomeh, Husam <HTomeh@facorelogic.com> wrote:
> We have a huge table with hundred million records. We need to increase the
> size of an existing column with varchar type, and it has been running for
> more than 12 hours.
>
>
>
> We’re using: ALTER TABLE Property ALTER COLUMN "situs-number" TYPE
> varchar(30);
>
it's not better to have the field beign type text and don't worry
about length but just in check constraints if really necesary?
>
> 1) Can you explain what’s happening internally that make this a very
> long process? Does the table get re-created?
>
yes, and all it's indexes rebuild not just the one you dropped
and the FK's rechecked (don't think so but can't remember right now)?
>
>
> 2) Assuming the Alter statement finished successfully, And if I didn’t
> drop the index (on that column), do I have to rebuild the index? Does the
> index get invalidated for just alter the indexed column?
>
it's get rebuilt
>
>
> 3) Some folks referred to directly updating Postgres internal tables
> (pg_attribute) which takes seconds to make the column change happen. How
> safe if this and would potentially cause any corruption?
>
no, that's insane
>
> 4) Is there a more practical and safe method to alter a huge table
> with reasonable amount of time?
>
>
use text fields instead of varchar(n)
--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157
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: jcasanov@systemguards.com.ec, HTomeh@facorelogic.com
Subject: Re: Altering a column (increasing size) in Postgres takes long time
In-Reply-To: <3073cc9b1002251540s8b91e7cw844b3bb6da2a0cd@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox