Disk Organization
Disk Organization
1
2 Disk Space Management
Linked List
Bitmap
A bitmap also allows very fast identification and
allocation of contiguous areas on disk.
4 Buffer Management in a
DBMS
Data must be in RAM for DBMS to operate on it!
Table of <frame#, pageid> pairs is maintained.
Page Requests from Higher Levels
BUFFER POOL
disk page
free frame
MAIN MEMORY
The LRU and clock policies are not always the best
replacement strategies
# buffer frames < # pages in file
#buffer frames=10, # pages in file =11,
means each page request causes an I/O.
Disadvantages:
If records are of variable length, all pages will be in free list.
because it is likely that every page has at least a few free bytes
Retrieve and examine several pages for enough
space.
15 Alternative 2: Heap File Using
Page Directory
In directory, each entry
Data for a page includes
Header Page 1 number of free bytes
Page on page.
Data The directory is a
Page 2 collection of pages
(linked list
implementation is just
one alternative).
Data Much smaller than
DIRECTORY Page N linked list of all HF
pages!
16 Alternative 2: Heap File Using
a Page Directory
Advantage of Page Directory :
The size of directory is very small (much smaller than heap
file.)
Searching space is very efficient, because find free
space without looking at actual heap data pages.
17 Page Formats
Identify a record:
Most cases, use <page_id, slot_number> as rid.
Disadvantage:
Does not work if there are external references to the record that
moved
19 Page Formats: Fixed Length
Records
Alternative 2:
Handle deletion using array of bit
One bit per slot to keep track of free slots
When a page is deleted, its bit is turned off (i.e. 0).
Locating records on the page requires scanning the bit
array to locate slots whose bit is on.
20 Page Formats: Fixed Length
Records
Record id = <page id, slot #>.
Slot 1 Slot 1
Slot 2 Slot 2
Free
... Space
...
Slot N Slot N
Slot M
N 1 . . . 0 1 1M
number
number M ... 3 2 1
of slots
PACKED of records UNPACKED, BITMAP
21 Page Formats: Variable
Length Records
Cannot divide the page into fixed-length slots
Challenges:
When a new record is to be inserted, we have to find an
empty slot of just the right length.
We must ensure that the free space on the page is
contiguous.
So
The ability to move records on a page becomes very
important
22 Page Formats: Variable
Length Records
Directory of slots
<record offset, record length> per slot
record offset: offset in bytes from the start of the data
area
Deletion: setting record offset to -1
rid <page id, slot id> does not change when a record
moves.
23 Page Formats: Variable
Length Records
Rid = (i,N) Length = 20 Offset of
Page i record
from start
Rid = (i,2) Length = 16 of data
area
Rid = (i,1) Length = 24
20 16 24 N Pointer
N ... 2 1 # slots to start
of free
space
SLOT DIRECTORY
F1 F2 F3 F4
L1 L2 L3 L4
4 $ $ $ $
Field
Fields Delimited by Special Symbols
Count
F1 F2 F3 F4