Re: remove flatfiles.c

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: remove flatfiles.c
Date: 2009-09-02 19:01:06
Message-ID: 407d949e0909021201j3b09e178t99de07d6bd1a7cc6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 2, 2009 at 6:57 PM, Kevin
Grittner<Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
> Greg Stark <gsstark(at)mit(dot)edu> wrote:
>
>> I don't think we want to cluster on the primary key. I think we just
>> want to rewrite the table keeping the same physical ordering.
>
> Well if that's what you want to do, couldn't you do something like?:
>
> Lock the table.
> Prop all indexes
> Pass the heap with two pointers, one to the first available empty
> space and one to the first non-dead row past that, and move inside the
> existing file.
> Rebuild the indexes.
> Release the lock.

Well dropping the indexes and moving tuples are both "hard" if you
care about crash-safety and transactional integrity.

The way we rewrite tables now is:

Lock table
Create new filenode.
Scan old table and copy each record into the new filenode keeping
update chains intact.
Rebuild all indexes for the table (using a similar strategy with new
relfilenodes)
Commit the transaction

If the transaction aborts at any point you still have the old pg_class
record which points to the old relfilenode and all the old indexes are
still valid.

We have all the pieces we need to do this, it's just a matter of
putting them together with a command to call them.

A big part of what VACUUM FULL is annoying is the complexity of moving
tuples in place. VACUUM FULL has to mark the old tuples and the new
copies with its xid. It can't truncate the relation until it commits
that xid.

Actually I wonder how much performance improvement would come on
normal DML just from not having to check xvac in the visibility
checks. It's probably not much but...

--
greg
http://mit.edu/~gsstark/resume.pdf

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-09-02 19:04:27 Re: remove flatfiles.c
Previous Message Peter Eisentraut 2009-09-02 18:56:42 Re: [COMMITTERS] pgsql: Derived files that are shipped in the distribution used to be