Re: files ending with .1 or .2 - Mailing list pgsql-general

From Tom Lane
Subject Re: files ending with .1 or .2
Date
Msg-id 3764.1098282773@sss.pgh.pa.us
Whole thread Raw
In response to Re: files ending with .1 or .2  (Leonardo Francalanci <lfrancalanci@simtel.ie>)
List pgsql-general
Leonardo Francalanci <lfrancalanci@simtel.ie> writes:
> Is there any documentation I can read about this?

The best concise documentation I know about is in the CVS-tip docs for
contrib/oid2name (reproduced below; the bit about tablespaces is
irrelevant to pre-8.0 versions, but the rest is accurate).  I've been
wanting to transpose this into the mainstream admin docs, but haven't
decided where to put it.

            regards, tom lane


Databases are placed in directories named after their OIDs in pg_database,
and the table files within a database's directory are named by "filenode"
numbers, which are stored in pg_class.relfilenode.

Note that while a table's filenode often matches its OID, this is *not*
necessarily the case; some operations, like TRUNCATE, REINDEX, CLUSTER
and some forms of ALTER TABLE, can change the filenode while preserving
the OID.  Avoid assuming that filenode and table OID are the same.

When a table exceeds 1Gb, it is divided into gigabyte-sized "segments".
The first segment's file name is the same as the filenode; subsequent
segments are named filenode.1, filenode.2, etc.

Tablespaces make the scenario more complicated.  Each non-default
tablespace has a symlink inside the pg_tblspc directory, which points to
the physical tablespace directory (as specified in its CREATE TABLESPACE
command).  The symlink is named after the tablespace's OID.  Inside the
physical tablespace directory there is another directory for each database
that has elements in the tablespace, named after the database's OID.
Tables within that directory follow the filenode naming scheme.  The
"pg_default" tablespace is not addressed via pg_tblspc, but corresponds to
$PGDATA/base.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Database Disappeared
Next
From: o.blomqvist@secomintl.com (Otto Blomqvist)
Date:
Subject: Views + UNION ALL = Slow ?