pg_filenode.map

A file which maps internal relations (mainly system catalogue tables) to their OID

pg_filenode.map is a special file which maps so-called "mapped relations" (i.e. those relations whose filenode is not stored in pg_class) to their OID.

pg_filenode.map was introduced in PostgreSQL 9.0 (commit b9b8831a).

There is one pg_filenode.map file per database, and one file for the entire cluster.

Currently each pg_filenode.map file is kept to 512 bytes (intended to occupy one standard-sized disk sector) to minimize risk of failed updates; the corresponding Struct is designed to occupy exactly 512 bytes and can contain a maximum of 62 entries (MAX_MAPPINGS) of 8 bytes each:

typedef struct RelMapping
{
	Oid			mapoid;			/* OID of a catalog */
	Oid			mapfilenode;	/* its filenode number */
} RelMapping;

with file metadata bringing the total up to 512:

typedef struct RelMapFile
{
	int32		magic;			/* always RELMAPPER_FILEMAGIC */
	int32		num_mappings;	/* number of valid RelMapping entries */
	RelMapping	mappings[MAX_MAPPINGS];
	pg_crc32c	crc;			/* CRC of all above */
	int32		pad;			/* to make the struct size be 512 exactly */
} RelMapFile;

For further details, see src/backend/utils/cache/relmapper.c.

Examples

Distribution of pg_filenode.map files in a data directory:

    postgres:data$ find . -name pg_filenode.map
    ./global/pg_filenode.map
    ./base/1/pg_filenode.map
    ./base/11787/pg_filenode.map
    ./base/11788/pg_filenode.map
    ./base/16385/pg_filenode.map

Categories

PostgreSQL internals, Storage