Data Layout on Disk

Understand the layout of fixed length and variable length records on a disk.

Database systems store the data on filesystems in the disk. The system further breaks down files into fixed-size units called pages. A page is a basic structure to organize data and index files on disk and the data transfer unit. Each page in the filesystem can hold from 4kb to 16kb.

Fixed-size page

The layout with fixed-size pages includes a group of pages, each with a constant size. A page or group of pages includes records of primitive and complex types. Every page contains data and a pointer to the next page. Each record on a fixed-size page should fit into a page. If the record size exceeds the page size, the layout uses pointers to connect multiple pages to store a single record.

The major problem with fixed-size pages is variable-size records. If the record size is less than the size of the page, the layout can only partially fit the data record. Unfortunately, this process leads to fragmentation and wasted space. The extra space remains unused unless there is a matching record with a similar size.

If the count of variable size records exceeds a threshold, the page layout will have a lot of fragmented free pages and is unable to fit new data records even though the cumulative free space is sufficient to hold it.

Get hands-on with 1200+ tech skills courses.