{"Entry":{"collection":"storage","key":"storage-file-layout","name":"Database File Layout","aliases":[],"metadata":{"aliases":[],"category":"Physical structures","content_hash":"d087d4825abb40c7a4f14d629ad694390737b1880427cf8252a74fcc36f249c9","imported_at":"2026-09-30T00:40:47.062531+08:00","name":"Database File Layout","name_zh":"","slug":"storage-file-layout","summary":"This section describes the storage format at the level of files and directories."}},"Definition":{"Collection":"storage","Key":"storage-file-layout","SourceDatabase":"center","Version":"18","SourceTable":"storage_structure","SourceKey":"storage-file-layout","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"comparison_data":{"layouts":[{"columns":[{"key":"c0","label":"Item"},{"key":"c1","label":"Description"}],"key":"layout-0","rows":[{"c0":"PG_VERSION","c1":"A file containing the major version number of PostgreSQL"},{"c0":"base","c1":"Subdirectory containing per-database subdirectories"},{"c0":"current_logfiles","c1":"File recording the log file(s) currently written to by the logging collector"},{"c0":"global","c1":"Subdirectory containing cluster-wide tables, such as pg_database"},{"c0":"pg_commit_ts","c1":"Subdirectory containing transaction commit timestamp data"},{"c0":"pg_dynshmem","c1":"Subdirectory containing files used by the dynamic shared memory subsystem"},{"c0":"pg_logical","c1":"Subdirectory containing status data for logical decoding"},{"c0":"pg_multixact","c1":"Subdirectory containing multitransaction status data (used for shared row locks)"},{"c0":"pg_notify","c1":"Subdirectory containing LISTEN/NOTIFY status data"},{"c0":"pg_replslot","c1":"Subdirectory containing replication slot data"},{"c0":"pg_serial","c1":"Subdirectory containing information about committed serializable transactions"},{"c0":"pg_snapshots","c1":"Subdirectory containing exported snapshots"},{"c0":"pg_stat","c1":"Subdirectory containing permanent files for the statistics subsystem"},{"c0":"pg_stat_tmp","c1":"Subdirectory containing temporary files for the statistics subsystem"},{"c0":"pg_subtrans","c1":"Subdirectory containing subtransaction status data"},{"c0":"pg_tblspc","c1":"Subdirectory containing symbolic links to tablespaces"},{"c0":"pg_twophase","c1":"Subdirectory containing state files for prepared transactions"},{"c0":"pg_wal","c1":"Subdirectory containing WAL (Write Ahead Log) files"},{"c0":"pg_xact","c1":"Subdirectory containing transaction commit status data"},{"c0":"postgresql.auto.conf","c1":"A file used for storing configuration parameters that are set by ALTER SYSTEM"},{"c0":"postmaster.opts","c1":"A file recording the command-line options the server was last started with"},{"c0":"postmaster.pid","c1":"A lock file recording the current postmaster process ID (PID), cluster data directory path, postmaster start timestamp, port number, Unix-domain socket directory path (could be empty), first valid listen_address (IP address or * , or empty if not listening on TCP), and shared memory segment ID (this file is not present after server shutdown)"}],"title":"Contents of PGDATA"}]},"comparison_hash":"6a33c677ffbfe17d60a976fb592903ea0b99fc5b534b695392130aee3fceaff0","description":["This section describes the storage format at the level of files and directories."],"facts":[{"label":"Definition scope","value":"Same-version core physical storage documentation"}],"manual_html":"\u003cdiv class=\"sect1\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e66.1. Database File Layout \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThis section describes the storage format at the level of files and directories.\u003c/p\u003e\n\u003cp\u003eTraditionally, the configuration and data files used by a database cluster are stored together within the cluster's data directory, commonly referred to as \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e (after the name of the environment variable that can be used to define it). A common location for \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e is \u003ccode class=\"filename\"\u003e/var/lib/pgsql/data\u003c/code\u003e. Multiple clusters, managed by different server instances, can exist on the same machine.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e directory contains several subdirectories and control files, as shown in \u003ca class=\"xref\" href=\"/docs/18/storage-file-layout.html#PGDATA-CONTENTS-TABLE\" title=\"Table 66.1. Contents of PGDATA\"\u003eTable 66.1\u003c/a\u003e. In addition to these required items, the cluster configuration files \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e, \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e, and \u003ccode class=\"filename\"\u003epg_ident.conf\u003c/code\u003e are traditionally stored in \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e, although it is possible to place them elsewhere.\u003c/p\u003e\n\u003cdiv class=\"table\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 66.1. Contents of \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eItem\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003ePG_VERSION\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA file containing the major version number of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003ebase\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing per-database subdirectories\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003ecurrent_logfiles\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eFile recording the log file(s) currently written to by the logging collector\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003eglobal\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing cluster-wide tables, such as \u003ccode class=\"structname\"\u003epg_database\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_commit_ts\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing transaction commit timestamp data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_dynshmem\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing files used by the dynamic shared memory subsystem\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_logical\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing status data for logical decoding\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_multixact\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing multitransaction status data (used for shared row locks)\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_notify\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing LISTEN/NOTIFY status data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_replslot\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing replication slot data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_serial\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing information about committed serializable transactions\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_snapshots\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing exported snapshots\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_stat\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing permanent files for the statistics subsystem\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_stat_tmp\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing temporary files for the statistics subsystem\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_subtrans\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing subtransaction status data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_tblspc\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing symbolic links to tablespaces\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_twophase\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing state files for prepared transactions\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing WAL (Write Ahead Log) files\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing transaction commit status data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epostgresql.auto.conf\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA file used for storing configuration parameters that are set by \u003ccode class=\"command\"\u003eALTER SYSTEM\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epostmaster.opts\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA file recording the command-line options the server was last started with\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epostmaster.pid\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA lock file recording the current postmaster process ID (PID), cluster data directory path, postmaster start timestamp, port number, Unix-domain socket directory path (could be empty), first valid listen_address (IP address or \u003ccode class=\"literal\"\u003e*\u003c/code\u003e, or empty if not listening on TCP), and shared memory segment ID (this file is not present after server shutdown)\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003cp\u003eFor each database in the cluster there is a subdirectory within \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/base\u003c/code\u003e, named after the database's OID in \u003ccode class=\"structname\"\u003epg_database\u003c/code\u003e. This subdirectory is the default location for the database's files; in particular, its system catalogs are stored there.\u003c/p\u003e\n\u003cp\u003eNote that the following sections describe the behavior of the builtin \u003ccode class=\"literal\"\u003eheap\u003c/code\u003e \u003ca class=\"link\" href=\"/docs/18/tableam.html\" title=\"Chapter 62. Table Access Method Interface Definition\"\u003etable access method\u003c/a\u003e, and the builtin \u003ca class=\"link\" href=\"/docs/18/indexam.html\" title=\"Chapter 63. Index Access Method Interface Definition\"\u003eindex access methods\u003c/a\u003e. Due to the extensible nature of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e, other access methods might work differently.\u003c/p\u003e\n\u003cp\u003eEach table and index is stored in a separate file. For ordinary relations, these files are named after the table or index's \u003cem class=\"firstterm\"\u003efilenode\u003c/em\u003e number, which can be found in \u003ccode class=\"structname\"\u003epg_class\u003c/code\u003e.\u003ccode class=\"structfield\"\u003erelfilenode\u003c/code\u003e. But for temporary relations, the file name is of the form \u003ccode class=\"literal\"\u003et\u003cem class=\"replaceable\"\u003e\u003ccode\u003eBBB\u003c/code\u003e\u003c/em\u003e_\u003cem class=\"replaceable\"\u003e\u003ccode\u003eFFF\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eBBB\u003c/code\u003e\u003c/em\u003e is the process number of the backend which created the file, and \u003cem class=\"replaceable\"\u003e\u003ccode\u003eFFF\u003c/code\u003e\u003c/em\u003e is the filenode number. In either case, in addition to the main file (a/k/a main fork), each table and index has a \u003cem class=\"firstterm\"\u003efree space map\u003c/em\u003e (see \u003ca class=\"xref\" href=\"/docs/18/storage-fsm.html\" title=\"66.3. Free Space Map\"\u003eSection 66.3\u003c/a\u003e), 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 \u003ccode class=\"literal\"\u003e_fsm\u003c/code\u003e. Tables also have a \u003cem class=\"firstterm\"\u003evisibility map\u003c/em\u003e, stored in a fork with the suffix \u003ccode class=\"literal\"\u003e_vm\u003c/code\u003e, to track which pages are known to have no dead tuples. The visibility map is described further in \u003ca class=\"xref\" href=\"/docs/18/storage-vm.html\" title=\"66.4. Visibility Map\"\u003eSection 66.4\u003c/a\u003e. Unlogged tables and indexes have a third fork, known as the initialization fork, which is stored in a fork with the suffix \u003ccode class=\"literal\"\u003e_init\u003c/code\u003e (see \u003ca class=\"xref\" href=\"/docs/18/storage-init.html\" title=\"66.5. The Initialization Fork\"\u003eSection 66.5\u003c/a\u003e).\u003c/p\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003eNote that while a table's filenode often matches its OID, this is \u003cspan class=\"emphasis\"\u003e\u003cem\u003enot\u003c/em\u003e\u003c/span\u003e necessarily the case; some operations, like \u003ccode class=\"command\"\u003eTRUNCATE\u003c/code\u003e, \u003ccode class=\"command\"\u003eREINDEX\u003c/code\u003e, \u003ccode class=\"command\"\u003eCLUSTER\u003c/code\u003e and some forms of \u003ccode class=\"command\"\u003eALTER TABLE\u003c/code\u003e, can change the filenode while preserving the OID. Avoid assuming that filenode and table OID are the same. Also, for certain system catalogs including \u003ccode class=\"structname\"\u003epg_class\u003c/code\u003e itself, \u003ccode class=\"structname\"\u003epg_class\u003c/code\u003e.\u003ccode class=\"structfield\"\u003erelfilenode\u003c/code\u003e contains zero. The actual filenode number of these catalogs is stored in a lower-level data structure, and can be obtained using the \u003ccode class=\"function\"\u003epg_relation_filenode()\u003c/code\u003e function.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eWhen a table or index exceeds 1 GB, it is divided into gigabyte-sized \u003cem class=\"firstterm\"\u003esegments\u003c/em\u003e. The first segment's file name is the same as the filenode; subsequent segments are named filenode.1, filenode.2, etc. This arrangement avoids problems on platforms that have file size limitations. (Actually, 1 GB is just the default segment size. The segment size can be adjusted using the configuration option \u003ccode class=\"option\"\u003e--with-segsize\u003c/code\u003e when building \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e.) In principle, free space map and visibility map forks could require multiple segments as well, though this is unlikely to happen in practice.\u003c/p\u003e\n\u003cp\u003eA table that has columns with potentially large entries will have an associated \u003cem class=\"firstterm\"\u003eTOAST\u003c/em\u003e table, which is used for out-of-line storage of field values that are too large to keep in the table rows proper. \u003ccode class=\"structname\"\u003epg_class\u003c/code\u003e.\u003ccode class=\"structfield\"\u003ereltoastrelid\u003c/code\u003e links from a table to its TOAST table, if any. See \u003ca class=\"xref\" href=\"/docs/18/storage-toast.html\" title=\"66.2. TOAST\"\u003eSection 66.2\u003c/a\u003e for more information.\u003c/p\u003e\n\u003cp\u003eThe contents of tables and indexes are discussed further in \u003ca class=\"xref\" href=\"/docs/18/storage-page-layout.html\" title=\"66.6. Database Page Layout\"\u003eSection 66.6\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eTablespaces make the scenario more complicated. Each user-defined tablespace has a symbolic link inside the \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/pg_tblspc\u003c/code\u003e directory, which points to the physical tablespace directory (i.e., the location specified in the tablespace's \u003ccode class=\"command\"\u003eCREATE TABLESPACE\u003c/code\u003e command). This symbolic link is named after the tablespace's OID. Inside the physical tablespace directory there is a subdirectory with a name that depends on the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server version, such as \u003ccode class=\"literal\"\u003ePG_9.0_201008051\u003c/code\u003e. (The reason for using this subdirectory is so that successive versions of the database can use the same \u003ccode class=\"command\"\u003eCREATE TABLESPACE\u003c/code\u003e location value without conflicts.) Within the version-specific subdirectory, there is a subdirectory for each database that has elements in the tablespace, named after the database's OID. Tables and indexes are stored within that directory, using the filenode naming scheme. The \u003ccode class=\"literal\"\u003epg_default\u003c/code\u003e tablespace is not accessed through \u003ccode class=\"filename\"\u003epg_tblspc\u003c/code\u003e, but corresponds to \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/base\u003c/code\u003e. Similarly, the \u003ccode class=\"literal\"\u003epg_global\u003c/code\u003e tablespace is not accessed through \u003ccode class=\"filename\"\u003epg_tblspc\u003c/code\u003e, but corresponds to \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/global\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"function\"\u003epg_relation_filepath()\u003c/code\u003e function shows the entire path (relative to \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e) of any relation. It is often useful as a substitute for remembering many of the above rules. But keep in mind that this function just gives the name of the first segment of the main fork of the relation — you may need to append a segment number and/or \u003ccode class=\"literal\"\u003e_fsm\u003c/code\u003e, \u003ccode class=\"literal\"\u003e_vm\u003c/code\u003e, or \u003ccode class=\"literal\"\u003e_init\u003c/code\u003e to find all the files associated with the relation.\u003c/p\u003e\n\u003cp\u003eTemporary files (for operations such as sorting more data than can fit in memory) are created within \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/base/pgsql_tmp\u003c/code\u003e, or within a \u003ccode class=\"filename\"\u003epgsql_tmp\u003c/code\u003e subdirectory of a tablespace directory if a tablespace other than \u003ccode class=\"literal\"\u003epg_default\u003c/code\u003e is specified for them. The name of a temporary file has the form \u003ccode class=\"filename\"\u003epgsql_tmp\u003cem class=\"replaceable\"\u003e\u003ccode\u003ePPP\u003c/code\u003e\u003c/em\u003e.\u003cem class=\"replaceable\"\u003e\u003ccode\u003eNNN\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003ePPP\u003c/code\u003e\u003c/em\u003e is the PID of the owning backend and \u003cem class=\"replaceable\"\u003e\u003ccode\u003eNNN\u003c/code\u003e\u003c/em\u003e distinguishes different temporary files of that backend.\u003c/p\u003e\n\u003c/div\u003e","manual_path":"/docs/18/storage-file-layout.html","related":[{"label":"Table AM","url":"/wiki/tableam/?v=18"},{"label":"Storage Parameters","url":"/wiki/relopts/?v=18"}],"release":{"channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"signature":"","sources":[{"label":"PostgreSQL 18 English manual","path":"storage-file-layout.html","sha256":"8cdf46b5af669f41f0a77c2541863d63454ef8fbb44d22a75e576cf1a7efc9c9","url":"/docs/18/storage-file-layout.html"}],"tables":[{"columns":[{"key":"c0","label":"Item"},{"key":"c1","label":"Description"}],"key":"layout-0","rows":[{"c0":"PG_VERSION","c1":"A file containing the major version number of PostgreSQL"},{"c0":"base","c1":"Subdirectory containing per-database subdirectories"},{"c0":"current_logfiles","c1":"File recording the log file(s) currently written to by the logging collector"},{"c0":"global","c1":"Subdirectory containing cluster-wide tables, such as pg_database"},{"c0":"pg_commit_ts","c1":"Subdirectory containing transaction commit timestamp data"},{"c0":"pg_dynshmem","c1":"Subdirectory containing files used by the dynamic shared memory subsystem"},{"c0":"pg_logical","c1":"Subdirectory containing status data for logical decoding"},{"c0":"pg_multixact","c1":"Subdirectory containing multitransaction status data (used for shared row locks)"},{"c0":"pg_notify","c1":"Subdirectory containing LISTEN/NOTIFY status data"},{"c0":"pg_replslot","c1":"Subdirectory containing replication slot data"},{"c0":"pg_serial","c1":"Subdirectory containing information about committed serializable transactions"},{"c0":"pg_snapshots","c1":"Subdirectory containing exported snapshots"},{"c0":"pg_stat","c1":"Subdirectory containing permanent files for the statistics subsystem"},{"c0":"pg_stat_tmp","c1":"Subdirectory containing temporary files for the statistics subsystem"},{"c0":"pg_subtrans","c1":"Subdirectory containing subtransaction status data"},{"c0":"pg_tblspc","c1":"Subdirectory containing symbolic links to tablespaces"},{"c0":"pg_twophase","c1":"Subdirectory containing state files for prepared transactions"},{"c0":"pg_wal","c1":"Subdirectory containing WAL (Write Ahead Log) files"},{"c0":"pg_xact","c1":"Subdirectory containing transaction commit status data"},{"c0":"postgresql.auto.conf","c1":"A file used for storing configuration parameters that are set by ALTER SYSTEM"},{"c0":"postmaster.opts","c1":"A file recording the command-line options the server was last started with"},{"c0":"postmaster.pid","c1":"A lock file recording the current postmaster process ID (PID), cluster data directory path, postmaster start timestamp, port number, Unix-domain socket directory path (could be empty), first valid listen_address (IP address or * , or empty if not listening on TCP), and shared memory segment ID (this file is not present after server shutdown)"}],"title":"Contents of PGDATA"}]},"ManualEvidence":{"manual_path":"/docs/18/storage-file-layout.html","release":{"channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"label":"PostgreSQL 18 English manual","path":"storage-file-layout.html","sha256":"8cdf46b5af669f41f0a77c2541863d63454ef8fbb44d22a75e576cf1a7efc9c9","url":"/docs/18/storage-file-layout.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"storage","Key":"storage-file-layout","SourceDatabase":"center","Version":"18","Locale":"en","Title":"Database File Layout","Summary":"This section describes the storage format at the level of files and directories.","BodyHTML":"\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2\u003e66.1. Database File Layout \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThis section describes the storage format at the level of files and directories.\u003c/p\u003e\n\u003cp\u003eTraditionally, the configuration and data files used by a database cluster are stored together within the cluster\u0026#39;s data directory, commonly referred to as \u003ccode\u003ePGDATA\u003c/code\u003e (after the name of the environment variable that can be used to define it). A common location for \u003ccode\u003ePGDATA\u003c/code\u003e is \u003ccode\u003e/var/lib/pgsql/data\u003c/code\u003e. Multiple clusters, managed by different server instances, can exist on the same machine.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003ePGDATA\u003c/code\u003e directory contains several subdirectories and control files, as shown in \u003ca href=\"/docs/18/storage-file-layout.html#PGDATA-CONTENTS-TABLE\" rel=\"nofollow\"\u003eTable 66.1\u003c/a\u003e. In addition to these required items, the cluster configuration files \u003ccode\u003epostgresql.conf\u003c/code\u003e, \u003ccode\u003epg_hba.conf\u003c/code\u003e, and \u003ccode\u003epg_ident.conf\u003c/code\u003e are traditionally stored in \u003ccode\u003ePGDATA\u003c/code\u003e, although it is possible to place them elsewhere.\u003c/p\u003e\n\u003cdiv\u003e\n\u003cp\u003e\u003cstrong\u003eTable 66.1. Contents of \u003ccode\u003ePGDATA\u003c/code\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv\u003e\n\u003ctable\u003e\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eItem\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003ePG_VERSION\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA file containing the major version number of \u003cspan\u003ePostgreSQL\u003c/span\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003ebase\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing per-database subdirectories\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003ecurrent_logfiles\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eFile recording the log file(s) currently written to by the logging collector\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003eglobal\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing cluster-wide tables, such as \u003ccode\u003epg_database\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_commit_ts\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing transaction commit timestamp data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_dynshmem\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing files used by the dynamic shared memory subsystem\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_logical\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing status data for logical decoding\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_multixact\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing multitransaction status data (used for shared row locks)\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_notify\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing LISTEN/NOTIFY status data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_replslot\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing replication slot data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_serial\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing information about committed serializable transactions\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_snapshots\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing exported snapshots\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_stat\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing permanent files for the statistics subsystem\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_stat_tmp\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing temporary files for the statistics subsystem\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_subtrans\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing subtransaction status data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_tblspc\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing symbolic links to tablespaces\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_twophase\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing state files for prepared transactions\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_wal\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing WAL (Write Ahead Log) files\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epg_xact\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing transaction commit status data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epostgresql.auto.conf\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA file used for storing configuration parameters that are set by \u003ccode\u003eALTER SYSTEM\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epostmaster.opts\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA file recording the command-line options the server was last started with\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003epostmaster.pid\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA lock file recording the current postmaster process ID (PID), cluster data directory path, postmaster start timestamp, port number, Unix-domain socket directory path (could be empty), first valid listen_address (IP address or \u003ccode\u003e*\u003c/code\u003e, or empty if not listening on TCP), and shared memory segment ID (this file is not present after server shutdown)\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr\u003e\n\u003cp\u003eFor each database in the cluster there is a subdirectory within \u003ccode\u003ePGDATA\u003c/code\u003e\u003ccode\u003e/base\u003c/code\u003e, named after the database\u0026#39;s OID in \u003ccode\u003epg_database\u003c/code\u003e. This subdirectory is the default location for the database\u0026#39;s files; in particular, its system catalogs are stored there.\u003c/p\u003e\n\u003cp\u003eNote that the following sections describe the behavior of the builtin \u003ccode\u003eheap\u003c/code\u003e \u003ca href=\"/docs/18/tableam.html\" rel=\"nofollow\"\u003etable access method\u003c/a\u003e, and the builtin \u003ca href=\"/docs/18/indexam.html\" rel=\"nofollow\"\u003eindex access methods\u003c/a\u003e. Due to the extensible nature of \u003cspan\u003ePostgreSQL\u003c/span\u003e, other access methods might work differently.\u003c/p\u003e\n\u003cp\u003eEach table and index is stored in a separate file. For ordinary relations, these files are named after the table or index\u0026#39;s \u003cem\u003efilenode\u003c/em\u003e number, which can be found in \u003ccode\u003epg_class\u003c/code\u003e.\u003ccode\u003erelfilenode\u003c/code\u003e. But for temporary relations, the file name is of the form \u003ccode\u003et\u003cem\u003e\u003ccode\u003eBBB\u003c/code\u003e\u003c/em\u003e_\u003cem\u003e\u003ccode\u003eFFF\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem\u003e\u003ccode\u003eBBB\u003c/code\u003e\u003c/em\u003e is the process number of the backend which created the file, and \u003cem\u003e\u003ccode\u003eFFF\u003c/code\u003e\u003c/em\u003e is the filenode number. In either case, in addition to the main file (a/k/a main fork), each table and index has a \u003cem\u003efree space map\u003c/em\u003e (see \u003ca href=\"/docs/18/storage-fsm.html\" rel=\"nofollow\"\u003eSection 66.3\u003c/a\u003e), 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 \u003ccode\u003e_fsm\u003c/code\u003e. Tables also have a \u003cem\u003evisibility map\u003c/em\u003e, stored in a fork with the suffix \u003ccode\u003e_vm\u003c/code\u003e, to track which pages are known to have no dead tuples. The visibility map is described further in \u003ca href=\"/docs/18/storage-vm.html\" rel=\"nofollow\"\u003eSection 66.4\u003c/a\u003e. Unlogged tables and indexes have a third fork, known as the initialization fork, which is stored in a fork with the suffix \u003ccode\u003e_init\u003c/code\u003e (see \u003ca href=\"/docs/18/storage-init.html\" rel=\"nofollow\"\u003eSection 66.5\u003c/a\u003e).\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eCaution\u003c/h3\u003e\n\u003cp\u003eNote that while a table\u0026#39;s filenode often matches its OID, this is \u003cspan\u003e\u003cem\u003enot\u003c/em\u003e\u003c/span\u003e necessarily the case; some operations, like \u003ccode\u003eTRUNCATE\u003c/code\u003e, \u003ccode\u003eREINDEX\u003c/code\u003e, \u003ccode\u003eCLUSTER\u003c/code\u003e and some forms of \u003ccode\u003eALTER TABLE\u003c/code\u003e, can change the filenode while preserving the OID. Avoid assuming that filenode and table OID are the same. Also, for certain system catalogs including \u003ccode\u003epg_class\u003c/code\u003e itself, \u003ccode\u003epg_class\u003c/code\u003e.\u003ccode\u003erelfilenode\u003c/code\u003e contains zero. The actual filenode number of these catalogs is stored in a lower-level data structure, and can be obtained using the \u003ccode\u003epg_relation_filenode()\u003c/code\u003e function.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eWhen a table or index exceeds 1 GB, it is divided into gigabyte-sized \u003cem\u003esegments\u003c/em\u003e. The first segment\u0026#39;s file name is the same as the filenode; subsequent segments are named filenode.1, filenode.2, etc. This arrangement avoids problems on platforms that have file size limitations. (Actually, 1 GB is just the default segment size. The segment size can be adjusted using the configuration option \u003ccode\u003e--with-segsize\u003c/code\u003e when building \u003cspan\u003ePostgreSQL\u003c/span\u003e.) In principle, free space map and visibility map forks could require multiple segments as well, though this is unlikely to happen in practice.\u003c/p\u003e\n\u003cp\u003eA table that has columns with potentially large entries will have an associated \u003cem\u003eTOAST\u003c/em\u003e table, which is used for out-of-line storage of field values that are too large to keep in the table rows proper. \u003ccode\u003epg_class\u003c/code\u003e.\u003ccode\u003ereltoastrelid\u003c/code\u003e links from a table to its TOAST table, if any. See \u003ca href=\"/docs/18/storage-toast.html\" rel=\"nofollow\"\u003eSection 66.2\u003c/a\u003e for more information.\u003c/p\u003e\n\u003cp\u003eThe contents of tables and indexes are discussed further in \u003ca href=\"/docs/18/storage-page-layout.html\" rel=\"nofollow\"\u003eSection 66.6\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eTablespaces make the scenario more complicated. Each user-defined tablespace has a symbolic link inside the \u003ccode\u003ePGDATA\u003c/code\u003e\u003ccode\u003e/pg_tblspc\u003c/code\u003e directory, which points to the physical tablespace directory (i.e., the location specified in the tablespace\u0026#39;s \u003ccode\u003eCREATE TABLESPACE\u003c/code\u003e command). This symbolic link is named after the tablespace\u0026#39;s OID. Inside the physical tablespace directory there is a subdirectory with a name that depends on the \u003cspan\u003ePostgreSQL\u003c/span\u003e server version, such as \u003ccode\u003ePG_9.0_201008051\u003c/code\u003e. (The reason for using this subdirectory is so that successive versions of the database can use the same \u003ccode\u003eCREATE TABLESPACE\u003c/code\u003e location value without conflicts.) Within the version-specific subdirectory, there is a subdirectory for each database that has elements in the tablespace, named after the database\u0026#39;s OID. Tables and indexes are stored within that directory, using the filenode naming scheme. The \u003ccode\u003epg_default\u003c/code\u003e tablespace is not accessed through \u003ccode\u003epg_tblspc\u003c/code\u003e, but corresponds to \u003ccode\u003ePGDATA\u003c/code\u003e\u003ccode\u003e/base\u003c/code\u003e. Similarly, the \u003ccode\u003epg_global\u003c/code\u003e tablespace is not accessed through \u003ccode\u003epg_tblspc\u003c/code\u003e, but corresponds to \u003ccode\u003ePGDATA\u003c/code\u003e\u003ccode\u003e/global\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003epg_relation_filepath()\u003c/code\u003e function shows the entire path (relative to \u003ccode\u003ePGDATA\u003c/code\u003e) of any relation. It is often useful as a substitute for remembering many of the above rules. But keep in mind that this function just gives the name of the first segment of the main fork of the relation — you may need to append a segment number and/or \u003ccode\u003e_fsm\u003c/code\u003e, \u003ccode\u003e_vm\u003c/code\u003e, or \u003ccode\u003e_init\u003c/code\u003e to find all the files associated with the relation.\u003c/p\u003e\n\u003cp\u003eTemporary files (for operations such as sorting more data than can fit in memory) are created within \u003ccode\u003ePGDATA\u003c/code\u003e\u003ccode\u003e/base/pgsql_tmp\u003c/code\u003e, or within a \u003ccode\u003epgsql_tmp\u003c/code\u003e subdirectory of a tablespace directory if a tablespace other than \u003ccode\u003epg_default\u003c/code\u003e is specified for them. The name of a temporary file has the form \u003ccode\u003epgsql_tmp\u003cem\u003e\u003ccode\u003ePPP\u003c/code\u003e\u003c/em\u003e.\u003cem\u003e\u003ccode\u003eNNN\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem\u003e\u003ccode\u003ePPP\u003c/code\u003e\u003c/em\u003e is the PID of the owning backend and \u003cem\u003e\u003ccode\u003eNNN\u003c/code\u003e\u003c/em\u003e distinguishes different temporary files of that backend.\u003c/p\u003e\n\u003c/div\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"03d22c43ccb539d6a04331063873b2e350286ae1ba4f62979251222c1836fc28","Payload":{"description":["This section describes the storage format at the level of files and directories."],"manual_html":"\u003cdiv class=\"sect1\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e66.1. Database File Layout \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThis section describes the storage format at the level of files and directories.\u003c/p\u003e\n\u003cp\u003eTraditionally, the configuration and data files used by a database cluster are stored together within the cluster's data directory, commonly referred to as \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e (after the name of the environment variable that can be used to define it). A common location for \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e is \u003ccode class=\"filename\"\u003e/var/lib/pgsql/data\u003c/code\u003e. Multiple clusters, managed by different server instances, can exist on the same machine.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e directory contains several subdirectories and control files, as shown in \u003ca class=\"xref\" href=\"/docs/18/storage-file-layout.html#PGDATA-CONTENTS-TABLE\" title=\"Table 66.1. Contents of PGDATA\"\u003eTable 66.1\u003c/a\u003e. In addition to these required items, the cluster configuration files \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e, \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e, and \u003ccode class=\"filename\"\u003epg_ident.conf\u003c/code\u003e are traditionally stored in \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e, although it is possible to place them elsewhere.\u003c/p\u003e\n\u003cdiv class=\"table\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 66.1. Contents of \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eItem\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003ePG_VERSION\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA file containing the major version number of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003ebase\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing per-database subdirectories\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003ecurrent_logfiles\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eFile recording the log file(s) currently written to by the logging collector\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003eglobal\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing cluster-wide tables, such as \u003ccode class=\"structname\"\u003epg_database\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_commit_ts\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing transaction commit timestamp data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_dynshmem\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing files used by the dynamic shared memory subsystem\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_logical\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing status data for logical decoding\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_multixact\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing multitransaction status data (used for shared row locks)\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_notify\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing LISTEN/NOTIFY status data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_replslot\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing replication slot data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_serial\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing information about committed serializable transactions\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_snapshots\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing exported snapshots\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_stat\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing permanent files for the statistics subsystem\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_stat_tmp\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing temporary files for the statistics subsystem\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_subtrans\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing subtransaction status data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_tblspc\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing symbolic links to tablespaces\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_twophase\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing state files for prepared transactions\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing WAL (Write Ahead Log) files\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epg_xact\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eSubdirectory containing transaction commit status data\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epostgresql.auto.conf\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA file used for storing configuration parameters that are set by \u003ccode class=\"command\"\u003eALTER SYSTEM\u003c/code\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epostmaster.opts\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA file recording the command-line options the server was last started with\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"filename\"\u003epostmaster.pid\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eA lock file recording the current postmaster process ID (PID), cluster data directory path, postmaster start timestamp, port number, Unix-domain socket directory path (could be empty), first valid listen_address (IP address or \u003ccode class=\"literal\"\u003e*\u003c/code\u003e, or empty if not listening on TCP), and shared memory segment ID (this file is not present after server shutdown)\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003cp\u003eFor each database in the cluster there is a subdirectory within \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/base\u003c/code\u003e, named after the database's OID in \u003ccode class=\"structname\"\u003epg_database\u003c/code\u003e. This subdirectory is the default location for the database's files; in particular, its system catalogs are stored there.\u003c/p\u003e\n\u003cp\u003eNote that the following sections describe the behavior of the builtin \u003ccode class=\"literal\"\u003eheap\u003c/code\u003e \u003ca class=\"link\" href=\"/docs/18/tableam.html\" title=\"Chapter 62. Table Access Method Interface Definition\"\u003etable access method\u003c/a\u003e, and the builtin \u003ca class=\"link\" href=\"/docs/18/indexam.html\" title=\"Chapter 63. Index Access Method Interface Definition\"\u003eindex access methods\u003c/a\u003e. Due to the extensible nature of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e, other access methods might work differently.\u003c/p\u003e\n\u003cp\u003eEach table and index is stored in a separate file. For ordinary relations, these files are named after the table or index's \u003cem class=\"firstterm\"\u003efilenode\u003c/em\u003e number, which can be found in \u003ccode class=\"structname\"\u003epg_class\u003c/code\u003e.\u003ccode class=\"structfield\"\u003erelfilenode\u003c/code\u003e. But for temporary relations, the file name is of the form \u003ccode class=\"literal\"\u003et\u003cem class=\"replaceable\"\u003e\u003ccode\u003eBBB\u003c/code\u003e\u003c/em\u003e_\u003cem class=\"replaceable\"\u003e\u003ccode\u003eFFF\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eBBB\u003c/code\u003e\u003c/em\u003e is the process number of the backend which created the file, and \u003cem class=\"replaceable\"\u003e\u003ccode\u003eFFF\u003c/code\u003e\u003c/em\u003e is the filenode number. In either case, in addition to the main file (a/k/a main fork), each table and index has a \u003cem class=\"firstterm\"\u003efree space map\u003c/em\u003e (see \u003ca class=\"xref\" href=\"/docs/18/storage-fsm.html\" title=\"66.3. Free Space Map\"\u003eSection 66.3\u003c/a\u003e), 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 \u003ccode class=\"literal\"\u003e_fsm\u003c/code\u003e. Tables also have a \u003cem class=\"firstterm\"\u003evisibility map\u003c/em\u003e, stored in a fork with the suffix \u003ccode class=\"literal\"\u003e_vm\u003c/code\u003e, to track which pages are known to have no dead tuples. The visibility map is described further in \u003ca class=\"xref\" href=\"/docs/18/storage-vm.html\" title=\"66.4. Visibility Map\"\u003eSection 66.4\u003c/a\u003e. Unlogged tables and indexes have a third fork, known as the initialization fork, which is stored in a fork with the suffix \u003ccode class=\"literal\"\u003e_init\u003c/code\u003e (see \u003ca class=\"xref\" href=\"/docs/18/storage-init.html\" title=\"66.5. The Initialization Fork\"\u003eSection 66.5\u003c/a\u003e).\u003c/p\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003eNote that while a table's filenode often matches its OID, this is \u003cspan class=\"emphasis\"\u003e\u003cem\u003enot\u003c/em\u003e\u003c/span\u003e necessarily the case; some operations, like \u003ccode class=\"command\"\u003eTRUNCATE\u003c/code\u003e, \u003ccode class=\"command\"\u003eREINDEX\u003c/code\u003e, \u003ccode class=\"command\"\u003eCLUSTER\u003c/code\u003e and some forms of \u003ccode class=\"command\"\u003eALTER TABLE\u003c/code\u003e, can change the filenode while preserving the OID. Avoid assuming that filenode and table OID are the same. Also, for certain system catalogs including \u003ccode class=\"structname\"\u003epg_class\u003c/code\u003e itself, \u003ccode class=\"structname\"\u003epg_class\u003c/code\u003e.\u003ccode class=\"structfield\"\u003erelfilenode\u003c/code\u003e contains zero. The actual filenode number of these catalogs is stored in a lower-level data structure, and can be obtained using the \u003ccode class=\"function\"\u003epg_relation_filenode()\u003c/code\u003e function.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eWhen a table or index exceeds 1 GB, it is divided into gigabyte-sized \u003cem class=\"firstterm\"\u003esegments\u003c/em\u003e. The first segment's file name is the same as the filenode; subsequent segments are named filenode.1, filenode.2, etc. This arrangement avoids problems on platforms that have file size limitations. (Actually, 1 GB is just the default segment size. The segment size can be adjusted using the configuration option \u003ccode class=\"option\"\u003e--with-segsize\u003c/code\u003e when building \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e.) In principle, free space map and visibility map forks could require multiple segments as well, though this is unlikely to happen in practice.\u003c/p\u003e\n\u003cp\u003eA table that has columns with potentially large entries will have an associated \u003cem class=\"firstterm\"\u003eTOAST\u003c/em\u003e table, which is used for out-of-line storage of field values that are too large to keep in the table rows proper. \u003ccode class=\"structname\"\u003epg_class\u003c/code\u003e.\u003ccode class=\"structfield\"\u003ereltoastrelid\u003c/code\u003e links from a table to its TOAST table, if any. See \u003ca class=\"xref\" href=\"/docs/18/storage-toast.html\" title=\"66.2. TOAST\"\u003eSection 66.2\u003c/a\u003e for more information.\u003c/p\u003e\n\u003cp\u003eThe contents of tables and indexes are discussed further in \u003ca class=\"xref\" href=\"/docs/18/storage-page-layout.html\" title=\"66.6. Database Page Layout\"\u003eSection 66.6\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eTablespaces make the scenario more complicated. Each user-defined tablespace has a symbolic link inside the \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/pg_tblspc\u003c/code\u003e directory, which points to the physical tablespace directory (i.e., the location specified in the tablespace's \u003ccode class=\"command\"\u003eCREATE TABLESPACE\u003c/code\u003e command). This symbolic link is named after the tablespace's OID. Inside the physical tablespace directory there is a subdirectory with a name that depends on the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server version, such as \u003ccode class=\"literal\"\u003ePG_9.0_201008051\u003c/code\u003e. (The reason for using this subdirectory is so that successive versions of the database can use the same \u003ccode class=\"command\"\u003eCREATE TABLESPACE\u003c/code\u003e location value without conflicts.) Within the version-specific subdirectory, there is a subdirectory for each database that has elements in the tablespace, named after the database's OID. Tables and indexes are stored within that directory, using the filenode naming scheme. The \u003ccode class=\"literal\"\u003epg_default\u003c/code\u003e tablespace is not accessed through \u003ccode class=\"filename\"\u003epg_tblspc\u003c/code\u003e, but corresponds to \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/base\u003c/code\u003e. Similarly, the \u003ccode class=\"literal\"\u003epg_global\u003c/code\u003e tablespace is not accessed through \u003ccode class=\"filename\"\u003epg_tblspc\u003c/code\u003e, but corresponds to \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/global\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"function\"\u003epg_relation_filepath()\u003c/code\u003e function shows the entire path (relative to \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e) of any relation. It is often useful as a substitute for remembering many of the above rules. But keep in mind that this function just gives the name of the first segment of the main fork of the relation — you may need to append a segment number and/or \u003ccode class=\"literal\"\u003e_fsm\u003c/code\u003e, \u003ccode class=\"literal\"\u003e_vm\u003c/code\u003e, or \u003ccode class=\"literal\"\u003e_init\u003c/code\u003e to find all the files associated with the relation.\u003c/p\u003e\n\u003cp\u003eTemporary files (for operations such as sorting more data than can fit in memory) are created within \u003ccode class=\"varname\"\u003ePGDATA\u003c/code\u003e\u003ccode class=\"filename\"\u003e/base/pgsql_tmp\u003c/code\u003e, or within a \u003ccode class=\"filename\"\u003epgsql_tmp\u003c/code\u003e subdirectory of a tablespace directory if a tablespace other than \u003ccode class=\"literal\"\u003epg_default\u003c/code\u003e is specified for them. The name of a temporary file has the form \u003ccode class=\"filename\"\u003epgsql_tmp\u003cem class=\"replaceable\"\u003e\u003ccode\u003ePPP\u003c/code\u003e\u003c/em\u003e.\u003cem class=\"replaceable\"\u003e\u003ccode\u003eNNN\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003ePPP\u003c/code\u003e\u003c/em\u003e is the PID of the owning backend and \u003cem class=\"replaceable\"\u003e\u003ccode\u003eNNN\u003c/code\u003e\u003c/em\u003e distinguishes different temporary files of that backend.\u003c/p\u003e\n\u003c/div\u003e","related":[{"label":"Table AM","url":"/wiki/tableam/?v=18"},{"label":"Storage Parameters","url":"/wiki/relopts/?v=18"}],"sections":[],"tables":[{"columns":[{"key":"c0","label":"Item"},{"key":"c1","label":"Description"}],"key":"layout-0","rows":[{"c0":"PG_VERSION","c1":"A file containing the major version number of PostgreSQL"},{"c0":"base","c1":"Subdirectory containing per-database subdirectories"},{"c0":"current_logfiles","c1":"File recording the log file(s) currently written to by the logging collector"},{"c0":"global","c1":"Subdirectory containing cluster-wide tables, such as pg_database"},{"c0":"pg_commit_ts","c1":"Subdirectory containing transaction commit timestamp data"},{"c0":"pg_dynshmem","c1":"Subdirectory containing files used by the dynamic shared memory subsystem"},{"c0":"pg_logical","c1":"Subdirectory containing status data for logical decoding"},{"c0":"pg_multixact","c1":"Subdirectory containing multitransaction status data (used for shared row locks)"},{"c0":"pg_notify","c1":"Subdirectory containing LISTEN/NOTIFY status data"},{"c0":"pg_replslot","c1":"Subdirectory containing replication slot data"},{"c0":"pg_serial","c1":"Subdirectory containing information about committed serializable transactions"},{"c0":"pg_snapshots","c1":"Subdirectory containing exported snapshots"},{"c0":"pg_stat","c1":"Subdirectory containing permanent files for the statistics subsystem"},{"c0":"pg_stat_tmp","c1":"Subdirectory containing temporary files for the statistics subsystem"},{"c0":"pg_subtrans","c1":"Subdirectory containing subtransaction status data"},{"c0":"pg_tblspc","c1":"Subdirectory containing symbolic links to tablespaces"},{"c0":"pg_twophase","c1":"Subdirectory containing state files for prepared transactions"},{"c0":"pg_wal","c1":"Subdirectory containing WAL (Write Ahead Log) files"},{"c0":"pg_xact","c1":"Subdirectory containing transaction commit status data"},{"c0":"postgresql.auto.conf","c1":"A file used for storing configuration parameters that are set by ALTER SYSTEM"},{"c0":"postmaster.opts","c1":"A file recording the command-line options the server was last started with"},{"c0":"postmaster.pid","c1":"A lock file recording the current postmaster process ID (PID), cluster data directory path, postmaster start timestamp, port number, Unix-domain socket directory path (could be empty), first valid listen_address (IP address or * , or empty if not listening on TCP), and shared memory segment ID (this file is not present after server shutdown)"}],"title":"Contents of PGDATA"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
