1.10 Chapter 1 Summary
The content of Chapter 1 can be summarized as follows.
- Instead of reading and writing the disk directly, a database brings pages into the buffer pool in memory. It then performs lookups or updates there. Dirty pages (pages modified in memory but not yet reflected on disk) are collected and periodically written to disk.
- It moves in units of pages. Even when one record is needed, it is read from disk in units of pages, because the cost of one disk access is high (Sections 1.1 to 1.3).
- Reads and writes happen in the buffer pool (memory). The longer frequently used pages stay in the buffer pool, the higher the cache hit ratio, so the buffer pool's size and replacement rules determine performance.
- Modified pages are not written to disk immediately. They remain as dirty pages and are written periodically by checkpoints, because even if the same page is changed many times, it needs to be written to disk only once.
Figure. Structure and behavior of pages, the buffer pool, dirty pages, and checkpoints
flowchart LR
Q["Query<br/>Lookups and updates"]
subgraph MEM ["Buffer pool (memory)"]
C["Clean page<br/>Same as the disk original"]
DP["Dirty page<br/>Modified only in memory"]
end
D["Disk<br/>Pages of the data file"]
D -->|"① Read in units of pages"| C
Q -->|"② Lookup"| C
Q -->|"③ Update"| DP
C -.->|"When modified"| DP
DP -->|"④ Written periodically by checkpoint"| D
The figure ties the content of this chapter into one flow.
- The database reads from the disk's data files in units of pages, not records, and loads them into the buffer pool (①). A page just read is a clean page whose content matches the disk original.
- Query lookups are handled on pages loaded in the buffer pool (②). While a page stays in the buffer pool, reading the same page again causes no disk I/O.
- Updates also happen on pages in the buffer pool, not on the disk (③). A modified page becomes a dirty page, as the dotted arrow shows.
- Dirty pages are not written to disk immediately but stay in the buffer pool until a checkpoint periodically writes them to disk (④). Even if the same page is modified several times in the meantime, only the final content is written to disk once.