Re: ALTER TABLE DROP COLUMN

From: The Hermit Hacker <scrappy(at)hub(dot)org>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>, PostgreSQL Development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: ALTER TABLE DROP COLUMN
Date: 2000-10-09 19:58:28
Message-ID: Pine.BSF.4.21.0010091658070.625-100000@thelab.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 9 Oct 2000, Bruce Momjian wrote:

> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > >> Basically, move the first 100 rows to the end of the table file, then take
> > >> 100 and write it to position 0, 101 to position 1, etc ... that way, at
> > >> max, you are using ( tuple * 100 ) bytes of disk space, vs 2x the table
> > >> size ... either method is going to lock the file for a period of time, but
> > >> one is much more friendly as far as disk space is concerned *plus*, if RAM
> > >> is available for this, it might even be something that the backend could
> > >> use up to -S blocks of RAM to do it off disk? If I set -S to 64meg, and
> > >> the table is 24Meg in size, it could do it all in memory?
> >
> > > Yes, I liked that too.
> >
> > What happens if you crash partway through?
> >
> > I don't think it's possible to build a crash-robust rewriting ALTER
> > process that doesn't use 2X disk space: you must have all the old tuples
> > AND all the new tuples down on disk simultaneously just before you
> > commit. The only way around 2X disk space is to adopt some logical
> > renumbering approach to the columns, so that you can pretend the dropped
> > column isn't there anymore when it really still is.
>
> Yes, I liked the 2X disk space, and making the new tuples visible all at
> once at the end.

man, are you ever wishy-washy on this issue, aren't you? :) you like not
using 2x, you like using 2x ... :)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-10-09 20:18:15 Re: Proposal for fixing numeric type-resolution issues
Previous Message Bruce Momjian 2000-10-09 19:58:25 Re: [GENERAL] rules on INSERT can't UPDATE new instance?