Objects in the PGDATA directory

Objects in the PGDATA directory

Content #

PostgreSQL does not name objects on disk, such as tables, in a mnemonic or human-readable way; instead, every file is named after a numeric identifier.

Internally, PostgreSQL holds a specific catalog that allows the database to match a mnemonic name to a numeric identifier, and vice versa. The integer identifier is named OID (or, Object Identifier); this name is a historical term that today corresponds to the so-called filenode.

[luyanfei@db base]$ oid2name
All databases:
    Oid  Database Name  Tablespace
----------------------------------
  13524       postgres  pg_default
  13523      template0  pg_default
      1      template1  pg_default
  16384           test  pg_default
[luyanfei@db 1]$ oid2name -d template1 -f 1255
From database "template1":
  Filenode  Table Name
----------------------
      1255     pg_proc

Every SQL table is stored as a file with a numeric name. However, PostgreSQL does not allow a single file to be greater than 1 GB in size.

so what happens if a table grows beyond that limit? PostgreSQL “attaches” another file with a numeric extension that indicates the next chunk of 1 GB of data. In other words, if your table is stored in the 123 file, the second gigabyte will be stored in the 123.1 file, and if another gigabyte of storage is needed, another file, 123.2, will be created. Therefore, the filenode refers to the very first file related to a specific table, but more than one file can be stored on disk.

From #