Tim
Tim

Reputation: 99478

Does PostgreSQL store a database per file, similarly to SQLite?

If I am correct, SQLite stores a database per file, and a file can't store more than one databases.

How does PostgreSQL store a database in terms of file(s)? Does it also store a database per file, and a file can't store more than one databases?

Upvotes: 1

Views: 344

Answers (1)

CL.
CL.

Reputation: 180162

(SQLite uses more than one file for the rollback journal or when in WAL mode.)

The PostgreSQL database file layout is documented in its documentation:

Each table and index is stored in a separate file. For ordinary relations, these files are named after the table or index's filenode number, which can be found in pg_class.relfilenode. […] in addition to the main file (a/k/a main fork), each table and index has a free space map …, which stores information about free space available in the relation. The free space map is stored in a file named with the filenode number plus the suffix _fsm. Tables also have a visibility map, stored in a fork with the suffix _vm, to track which pages are known to have no dead tuples. […]

Upvotes: 4

Related Questions