# 1.3 The Shipping Container (The Page)

Suitcases (Tuples) are small, but the Lazy Elephant’s hands are enormous. If the
elephant tried to pick up each suitcase individually, it would be exhausted
before the first query even finished.
To solve this, Postgres crams suitcases into standard-sized **Shipping
Containers** called **Pages**.
## The Standard Size (8KB)
"How curious!" you might exclaim. "Why 8KB? Why not as big as a house, or as small as a mouse?"
In most Postgres universes, every single shipping container is exactly **8KB** in size. This is because the elephant (the storage manager) has a very specific set of **8KB Gloves** that can ONLY grip containers of those exact dimensions. Whether a container is full of suitcases or mostly empty, the elephant always picks up the entire 8KB block. It’s a matter of fashion, you see!
## The Container Layout
If you were to slice a shipping container open, you would see a very clever organization system designed to keep the container balanced, much like a perfectly arranged tea set.
The most important thing to know is that the container is **Symmetric**. The Index (the "Bungee Hooks") grows from the front towards the back, while the actual Luggage (the "Suitcases") is stacked from the back towards the front. They grow toward each other until they meet in a beautiful, binary collision.
### The Schematic
```text
+---------------------------------+ <-- Page Start (Offset 0)
| Header (24 bytes) | (The Captain's Log)
+---------------------------------+ <-- pd_lower
| Item Pointers (4 bytes ea) | (The Bungee Hooks)
| [1] [2] [3] [4] ... | (Grow DOWN ↓)
+---------------------------------+
| |
| FREE SPACE | (The Gap)
| |
+---------------------------------+ <-- pd_upper
| |
| TUPLES (Data) | (The Suitcases)
| ... [4] [3] [2] [1] | (Grow UP ↑)
| |
+---------------------------------+
| Special Space (Optional) | (Only for Index Pages)
+---------------------------------+ <-- Page End (8,192 bytes)
```
### The Parts of the Page
1. **The Captain's Log (The Header):** At the very front of the container is a fixed 24-byte control panel. It records the container's version, a checksum, and strict memory pointers (`pd_lower` and `pd_upper`) defining the boundaries of the **Free Space**. Crucially, it also contains the **`pd_lsn`**, which is the exact **Log Sequence Number (LSN)** of the very last diary scribble that modified this container. It’s like a "Last Inspected By" stamp!
2. **The Bungee Hooks (Item Identifiers):** Hanging from the ceiling of the container are a series of numbered hooks called **Item Identifiers**. Each hook is a tiny 4-byte pointer that tells the elephant exactly where on the floor a specific suitcase is sitting. As you add more suitcases, the elephant adds more hooks, moving the `pd_lower` pointer deeper into the container.
3. **The Suitcases (Tuples):** The actual suitcases are stacked along the floor at the very end of the container. As new suitcases arrive, they are placed in the next available spot *moving backwards* toward the front of the container, shifting the `pd_upper` pointer.
4. **The Special Space:** At the very tail end of the container is a small, optional "Secret Compartment." Regular data tables don't use it, but **Index Pages** use it to store pointers to their siblings (Left and Right) so the elephant can run between containers without going back to the front office.
5. **The Free Space (The Gap):** In the middle of the container is the **Free Space**. The moment `pd_lower` meets `pd_upper`, the container is absolutely full! No more luggage can be added until the robotic vacuum cleaner ([[Workloads/Sub/Autovacuum|The Vacuum]]) comes by to clear out any suitcases marked with a "Dead" stamp.
### The Magnifying Glass (`pageinspect`)
If you want to actually peak inside one of these containers, you can use the **`pageinspect` magnifying glass**. This is a special extension that lets the elephant show you the literal binary guts of a page.
```sql
-- First, hire the Magnifying Glass expert
CREATE EXTENSION IF NOT EXISTS pageinspect;
-- Peek at the top-level stats of Page 0 of the 'animals' table
SELECT * FROM page_header(get_raw_page('animals', 0));
-- Results:
-- lsn | checksum | flags | lower | upper | special | pagesize
-- ------------+----------+-------+-------+-------+---------+----------
-- 0/16A5E88 | 0 | 0 | 28 | 8160 | 8192 | 8192
```
In the output above, you can see the **`lsn`** (the last diary entry), the **`pagesize`** (exactly 8192 bytes, or 8KB), and the **`lower`** and **`upper`** pointers that define the Free Space. It’s the ultimate proof that the shipping container is real!
---
| ← Previous | ↑ Table of Contents | Next → |
| :--- | :---: | ---: |
| [[Chapter 1/1.2 - The Physical Suitcase (The Tuple)\|1.2 The Physical Suitcase (The Tuple)]] | [[Learn You a Postgres for Great Good\|Home]] | [[Chapter 1/1.4 - The Depot (The Table)\|1.4 The Depot (The Table)]] |