Page Internals

COMP9315 21T1 ♢ Page Internals ♢ [0/18]
❖ Pages

Database applications view data as:

The disk and buffer manager provide the following view: Page format = how space/tuples are organised within a page
COMP9315 21T1 ♢ Page Internals ♢ [1/18]
❖ Pages (cont)


Data files consist of pages containing tuples:


[Diagram:Pics/storage/data-files.png]


Each data file (in PostgreSQL) is related to one table.

COMP9315 21T1 ♢ Page Internals ♢ [2/18]
❖ Page Formats

Ultimately, a Page is simply an array of bytes (byte[]).

We want to interpret/manipulate it as a collection of Records (tuples).

Tuples are addressed by a record ID  (rid = (PageId,TupIndex))

Typical operations on Pages:

COMP9315 21T1 ♢ Page Internals ♢ [3/18]
❖ Page Formats (cont)

Page format = tuples + data structures allowing tuples to be found

Characteristics of Page formats:

Implementation of Page operations critically depends on format.
COMP9315 21T1 ♢ Page Internals ♢ [4/18]
❖ Page Formats (cont)

For fixed-length records, use record slots.

[Diagram:Pics/storage/rec-slots.png]

COMP9315 21T1 ♢ Page Internals ♢ [5/18]
❖ Page Formats

For variable-length records, must use slot directory.

Possibilities for handling free-space within block:

In practice, a combination is useful:
Important aspect of using slot directory
COMP9315 21T1 ♢ Page Internals ♢ [6/18]
❖ Page Formats (cont)

Compacted free space:  

[Diagram:Pics/storage/free-list.png]

Note: "pointers" are implemented as word offsets within block.

COMP9315 21T1 ♢ Page Internals ♢ [7/18]
❖ Page Formats (cont)

Fragmented free space:  

[Diagram:Pics/storage/free-list1.png]

COMP9315 21T1 ♢ Page Internals ♢ [8/18]
❖ Page Formats (cont)

Initial page state (compacted free space) ...

[Diagram:Pics/storage/insert1a.png]

COMP9315 21T1 ♢ Page Internals ♢ [9/18]
❖ Page Formats (cont)

Before inserting record 7 (compacted free space) ...

[Diagram:Pics/storage/insert1b.png]

COMP9315 21T1 ♢ Page Internals ♢ [10/18]
❖ Page Formats (cont)

After inserting record 7 (80 bytes) ...

[Diagram:Pics/storage/insert1c.png]

COMP9315 21T1 ♢ Page Internals ♢ [11/18]
❖ Page Formats (cont)

Initial page state (fragmented free space) ...

[Diagram:Pics/storage/insert2a.png]

COMP9315 21T1 ♢ Page Internals ♢ [12/18]
❖ Page Formats (cont)

Before inserting record 7 (fragmented free space) ...

[Diagram:Pics/storage/insert2b.png]

COMP9315 21T1 ♢ Page Internals ♢ [13/18]
❖ Page Formats (cont)

After inserting record 7 (80 bytes) ...

[Diagram:Pics/storage/insert2c.png]

COMP9315 21T1 ♢ Page Internals ♢ [14/18]
❖ Storage Utilisation

How many records can fit in a page? (denoted C = capacity)

Depends on:

We typically consider average record size (R)

Given C,   HeaderSize + C*SlotSize + C*R  ≤  PageSize

COMP9315 21T1 ♢ Page Internals ♢ [15/18]
❖ Overflows

Sometimes, it may not be possible to insert a record into a page:

  1. no free-space fragment large enough
  2. overall free-space is not large enough
  3. the record is larger than the page
  4. no more free directory slots in page
For case (1), can first try to compact free-space within the page.

If still insufficient space, we need an alternative solution ...

COMP9315 21T1 ♢ Page Internals ♢ [16/18]
❖ Overflows (cont)

File organisation determines how cases (2)..(4) are handled.

If records may be inserted anywhere that there is free space

If file organisation determines record placement (e.g. hashed file) With overflow pages, rid structure may need modifying (rel,page,ovfl,rec)
COMP9315 21T1 ♢ Page Internals ♢ [17/18]
❖ Overflows (cont)

Overflow files for very large records and BLOBs:

[Diagram:Pics/storage/ovflow-file.png]

Record-based handling of overflows:

[Diagram:Pics/storage/ovflow-record.png]

We discuss overflow pages in more detail when covering Hash Files.

COMP9315 21T1 ♢ Page Internals ♢ [18/18]


Produced: 23 Feb 2021