Re: [HACKERS] tables > 1 gig - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] tables > 1 gig
Date
Msg-id 199906180315.XAA14659@candle.pha.pa.us
Whole thread Raw
In response to RE: [HACKERS] tables > 1 gig  ("Hiroshi Inoue" <Inoue@tpf.co.jp>)
Responses RE: [HACKERS] tables > 1 gig
List pgsql-hackers
> > > Unlinking unused segments after truncating to zero length may cause 
> > > the result such as 
> > > 
> > >      Existent backends write to the truncated file to extend 
> > the relation
> > >      while new backends create a new segment file to extend the 
> > relation. 
> > 
> > How about my idea of creating a truncated file, the renaming it to the
> > table file.  That keeps the table open for other open file descriptors,
> > but put a zero-length file in place in an atomic manner.
> >
> 
> Sorry,I couldn't understand what you mean.
> What is differenct from truncating existent files to zero length ?

Glad to explain.  Here is the pseudocode:
create temp file, make it zero length, call it 'zz'rename(zz,tablename)

What this does is to create a zero length file, and the rename unlinks
the tablename file, and puts the zero-length file in it's place. 
rename() is atomic, so there is no time that the table file does not
exist.

It allows backends that have the table open via a descriptor to keep the
table unchanged, while new backends see a zero-length file.

Does this help?


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: "Hiroshi Inoue"
Date:
Subject: RE: [HACKERS] tables > 1 gig
Next
From: "Hiroshi Inoue"
Date:
Subject: RE: [HACKERS] tables > 1 gig