Storage, Data Organization, and Buffering
Walid G. Aref
Storage, Data Organization, and Buffering Walid G. Aref Memory - - PowerPoint PPT Presentation
Storage, Data Organization, and Buffering Walid G. Aref Memory Hierarchy Archival Storage Higher (e.g., tapes) Capacity Network Storage Block-oriented access Non- Disk Storage Volatile Solid-State Disks Main Memory Byte-oriented
Walid G. Aref
Walid G. Aref
CPU Registers Cache Memory Main Memory Disk Storage Network Storage Solid-State Disks Non- Volatile Volatile Higher Capacity Higher Price Higher Speed Block-oriented access Byte-oriented access Archival Storage (e.g., tapes)
Walid G. Aref
(measured in RPM)
Walid G. Aref
Processor Main Memory Buffers Disk Storage Seek Time Rotational Delay Data Transfer Time
the disk to the memory buffers
buffers into the disk page corresponding to the given disk block id
Walid G. Aref
Sector Number)
relatively slow
1. Seek:
(uses an elevator algorithm)
2. Rotation:
Number
3. Transmission:
and give the signal to the head responsible for the blockβs Platter Number to start reading the block and transmit the bits to the disk driver buffers
Walid G. Aref
Cylinder Number
Transfer Time
Track
Walid G. Aref
Number
Transfer Time
Track
being requested (Prefetching)
time and each requesting to retrieve a different file at the same time.
Walid G. Aref
the table?
Walid G. Aref
Head Page 1 Page 2 Page n
two-level hierarchy (directory of pages)
Γ
Walid G. Aref
Page 1 Page 2 Page 3 1 2 3 4 5 n Page n
Γ Variable-length Records
Walid G. Aref
primary key side
Γ Variable-length Records
Walid G. Aref
the empty slots
Walid G. Aref
T3 T2 T1 Free Space Free Space Free Space TUPLE TUPLE
the empty slots
tuples
T3 T2 T1 Free Space Free Space TUPLE TUPLE 1 1
Next Pg. 1 Next Pg. 1 0 1 T3 T2 T1 Free Space Free Space TUPLE TUPLE Head of Free Space
Next Pg. Linked List
Free Space
tuples
chosen directory structure)
control purposes
Walid G. Aref
Walid G. Aref
contains offset of the tuple from the beginning of page
but the offset value in the entry changes
them contiguous with no empty space between them; entry in the header must be updated (Expensive β Should be avoided)
Next Pg. Ptr. Free Space In-page Directory Free Space Ptr. Free Space Size
Slots
Walid G. Aref
new tuple? Use Free Space Pointer and Free Space Size
insert/update
increases?
get deleted?
space, and given a new tuple to be inserted
Next Pg. Ptr. Free Space In-page Directory Free Space Ptr. Free Space Size
Slots
first page that contains space that can accommodate this tuple
page has more than one deleted tuple? Maintain priority queue inside each page?
Walid G. Aref
Head Page 1 Page 2 Page n Page F1 Page F2 Page Fm list of pages with some free space list of pages with no free space
the size of the free space in the corresponding page
contiguous free space
space resulting from deletions of tuples?
level priority queue for all the free space in all the individual pages?
Walid G. Aref
Page 1 Page 2 Page 3 1 2 3 4 5 n Page n Directory Pages Data Pages
tuple
$%# πππππ’β(π΅π’π’π πππ£π’π π)
&'(%)**+, πππππ’β(π΅π’π’π πππ£π’π π)
Walid G. Aref
Boolean
Length String T3 T2 T1 Free Space Free Space TUPLE TUPLE 1 1
1 Next Pg. 1 0 1
some attributes are of variable lengths
access an attribute
Steve Bucks\0 Delphi\0 Tippecanoe County\0 βNullβ\0 47905
Next Pg. Ptr. Free Space In-page Directory Free Space Ptr. Free Space Size
Slots
Walid G. Aref
= 0 Γ Attribute has null value (e.g., Attr. 4 below)
Next Pg. Ptr. Free Space In-page Directory Free Space Ptr. Free Space Size
Slots Steve Bucks Delphi Tippecanoe County 47905
Walid G. Aref
Header: Offset Array Notice there is no value for Attribute 4 (has Null value)
Walid G. Aref
tuples
need to change
maintain the sorted order
Walid G. Aref
T3 T2 T1 Free Space Free Space TUPLE TUPLE Head of Free Space
Next Pg. Linked List
Free Space Sorted
Head of Sorted Table
in sorted order into a page and the page is entirely full?
accommodate for overflow page
Walid G. Aref
T3 T2 T1 Free Space Free Space TUPLE TUPLE Head of Free Space
Next Pg. Linked List
Free Space Head of Sorted Table T1.2 T1.1 Overflow page
and produces the bucket (disk page) that contains the tuple
across pages, e.g., during b-tree page splits
Walid G. Aref
sid, grade) along with the tuple about the course info itself (cid, ctitle, credits, etc.)
different tuple sizes of the two tables)
Walid G. Aref
Walid G. Aref
table represents this view, its directory entry, etc.
(System Catalog is self describing)
which tables)
Walid G. Aref
relation_name, // Name of a table attribute_name, // Name of an attribute in the table attribute_type, // Type of this attribute attribute_order_in_table // Order of this attribute in the tuple, 1st , 2nd , 3rd, etc. )
Walid G. Aref
relation_name attribute_name attribute_type attribute_order_in_table Attributes_Catalog_Table relation_name string 1 Attributes_Catalog_Table attribute_name string 2 Attributes_Catalog_Table attribute_type string 3 Attributes_Catalog_Table attribute_order_in_table integer 4 instructors iid integer 1 instructors iname string 2 instructors rank string 3
Walid G. Aref
management?
join, project)
accessed next.
in the buffers and which pages that can be removed.
Walid G. Aref
memory for queries to operate on it.
these pages are stored.
data that gets transferred between disk and memory (Buffer Manager)
βBuffer Missesβ
as possible in memory
pages to buffer pages
Walid G. Aref
Disk Empty buffer pages Buffer pages filled with disk pages Disk Page Buffer Frame Number p1 b7 p12 b3 p4 b0 Buffer Mapping Table Buffer pool
been updated in the buffer pool or not since when the page has been first read from disk
buffer is a copy of that on disk
buffer is different from its corresponding page on disk
transactions that requested the page to be pinned in the buffer (i.e., is not allowed to be preempted out of the buffer). If pin count = 0, then page is candidate for preemption if buffer gets full
Walid G. Aref
Disk Empty buffer pages Buffer pages filled with disk pages Disk Page Buffer Frame Number p1 b7 p12 b3 p4 b0 Buffer Mapping Table Buffer pool Dirty Pages
Walid G. Aref
1. Use the Mapping Table to check if p is in the buffers 2. If yes (A Buffer Hit), then return the Frame id of the frame in the Buffer Pool that contains the requested page 3. Else, need to retrieve p from the disk 4. Find an empty buffer frame, say b, to store in it the retrieved page 5. If found, store p into b and insert the entry (p,b) into the Mapping Table for future use 6. If the buffer is entirely full, we need to find a disk page in the buffer to replace by p 7. Need to adopt some replacement policy to decide which page to preempt from the buffer pool
Walid G. Aref
Disk Empty buffer pages Buffer pages filled with disk pages Disk Page Buffer Frame Number p1 b7 p12 b3 p4 b0 Buffer Mapping Table Buffer pool
decided by the buffer replacement policy is Page q in buffer frame c
since being read from disk), then
Walid G. Aref
Disk Buffer pages filled with disk pages Disk Page Buffer Frame Number p1 b7 p12 b3 p4 b0 Buffer Mapping Table Buffer pool No empty buffer pages
was just being processed
the most attractive.
next.
Walid G. Aref
LRU page Current page (MRU) Outer Table Inner Table