# Table Architecture In PostgreSQL, a **Table** is a collection of logical rows physically stored as a set of fixed-size **Pages** in a "Heap" file. For the narrative explanation of this concept, see [[Chapter 1/1.4 - The Depot (The Table)|1.3 The Table (The Depot)]]. ## Storage Model - **Heap Storage**: PostgreSQL stores data in an unordered fashion known as a heap. Rows are placed in the first available space found via the Free Space Map (FSM). - **Filing Structure**: Each table is represented by one or more physical files on disk, typically named after the table's `relfilenode` in the `base/` directory. - **Segments**: Files are divided into 1GB segments to stay compatible with various filesystem limits. ## Table Forks A table consists of multiple "forks" or related files: 1. **Main Fork**: The actual data pages containing the tuples. 2. **Free Space Map (FSM)**: Tracks free space in each page. 3. **Visibility Map (VM)**: Tracks pages with all-visible tuples. 4. **TOAST Table**: A separate side-table for storing large column values (> 2KB). ## Access Methods - **Sequential Scan**: Reading every page in the heap from beginning to end. - **Index Scan**: Using an external structure to find the physical address (`ctid`) of a tuple in the heap. - **TID Scan**: Directly accessing a tuple by its physical location (Block number, Offset). ## See Also - [[Structures/Page|Page Structure]] - [[Structures/Tuple|Tuple Structure]] - [[Architecture/MVCC|MVCC]]