Storage & Retrieval of Data
Database Storage: From Records to Page Reads
Database Storage connects the records you work with to the bytes that hold them. A table containing thousands of records is normally stored across many physical pages, and retrieving a small result can still require several page reads. Understanding this layer helps you estimate storage requirements and explain why record placement and caching affect retrieval, without needing to write a query.
Pages connect records to storage
A page is a fixed-size unit that a database storage manager organizes and transfers between persistent storage and memory. A page can contain several records. Persistent storage retains the database when its ordinary in-memory copies disappear.
A common page design includes a header, a slot directory, record bytes and free space. The header describes the page. Each slot identifies where one record sits, allowing its bytes to move within the page while the slot continues to locate it. Exact layouts vary between database implementations.
The buffer pool is the database-managed memory area that holds copies of pages. If a requested page is already there, the database can use the copy without fetching that page from persistent storage again. A clean, unmodified copy can be discarded without deleting the stored records. Modified pages require additional write-management rules, beyond the read-cost model here.
Calculate space using a stated layout
For a simplified fixed-length layout, let P be bytes per page, H fixed page overhead, R bytes per record including its record header, and S slot bytes per record. If records cannot cross page boundaries, capacity is
The floor brackets mean round down to a whole number. Provided c≥1, storing N records on pages filled to this capacity requires
The ceiling brackets mean round up: a partly occupied final page still occupies a whole page. These equations describe the stated model. Variable-length records, reserved free space and other implementation overhead can change actual capacity.
Unused bytes within allocated pages still count toward allocated storage. Also, BP describes these table pages only; it does not automatically include indexes or other database files.
Placement changes retrieval cost
A heap file can place a new record wherever suitable space exists. An index supplies searchable entries that help locate records, but following an index can require reading both index pages and table pages.
Storage arrangement | Retrieval implication | Storage or maintenance implication |
|---|---|---|
Unordered heap without a useful index | A full scan may inspect every table page | No required search-key ordering |
Records grouped by the search key | Nearby matching records may share pages | Maintaining the grouping can require extra work |
Separate index over a heap | Index entries locate records whose pages may be scattered | Index pages occupy space and need maintenance |
For a particular access, count distinct required pages that are absent from the buffer pool:
A cold-cache model starts with none of the relevant pages cached. Under that assumption, a full scan reads all B table pages. An index-based retrieval reads its required index pages plus its distinct required table pages. Several matching records on one page need only one read of that page, provided it remains available in memory.
Page-read counts explain storage traffic, but they do not determine elapsed time alone. Sequential access, scattered access, device behaviour and processing work also matter.
What to remember
- Pages contain both records and overhead.
- Round record capacity down and required page count up.
- Record placement determines how many distinct table pages a retrieval touches.
- Cached pages can reduce storage reads without changing the stored table size.
- Fewer page reads alone do not guarantee a shorter running time.
Example: Planning a Sensor Archive
A monitoring team archives 14,500 fixed-length sensor records. Each table page contains 8,192 bytes, with 192 bytes reserved for fixed page overhead. Each record occupies 196 bytes, including its record header, and needs a separate 4-byte slot entry. The record footprint is the total page space required by one record and its slot entry.
Assume records cannot span pages, pages are filled to maximum capacity before another page is used, and there is no additional overhead. Calculate table storage separately from index storage.
a) How many records fit on one page?
First remove the fixed overhead. The usable space is ________. Then combine the stored record and its slot entry: the record footprint is ________.
Divide usable space by the footprint, rounding down because a fraction of a record cannot occupy the remaining space.
The page capacity is 40 records. As a check, 40×200=8000 bytes exactly fills the usable space.
b) How many table pages are required, and how many bytes do those pages occupy?
Divide the number of records by the capacity. Before rounding, the quotient is ________.
The first 362 full pages hold 362×40=14,480 records. The remaining 20 records require one additional page, even though it will be only partly occupied.
Multiply by the complete page size, including overhead and unused space in the final page.
The table requires 363 pages occupying 2,973,696 bytes. This excludes index pages and other database files.
c) A lookup retrieves one archived record. Its index traversal requires three distinct index pages, followed by one table page. Compare its storage page reads with a full scan of the table. Both operations start independently with empty caches, retain pages once read, and access no other pages.
For the index-based lookup, the index contributes ________ and the table contributes ________. Each required page is initially absent from memory.
A full scan reads every allocated table page, including the partly occupied final page. It does not also traverse the index.
The lookup requires 4 storage page reads, compared with 363 for the full scan, a reduction of 363−4=359 reads. This comparison measures page reads, not a guaranteed elapsed-time ratio. The different access patterns can have different costs per read.
A database designer is comparing physical storage choices for an archive. Match each organization or access structure to its defining property. A search key need not uniquely identify a record.
Maintains data records in search-key order so nearby key values are stored together.
Stores records wherever space is available without maintaining search-key order.
Uses a balanced hierarchy of ordered entries and linked leaves to support equality and range searches.
Maps a search-key value to a bucket for equality searches without maintaining an ordered sequence of keys.
B+ tree index
Heap file
Sorted file
Hash index
A laboratory database stores 9,400 fixed-length records. Each page contains 4,096 bytes, including 96 bytes of fixed page overhead. Each record occupies 150 bytes, including its record header, and requires a separate 10-byte slot entry. Records cannot span pages, and pages are filled to maximum capacity before another page is used. How many table pages are required? Answer in pages, as a whole number with zero decimal places.