9.1 Storage Hierarchy
The storage of a computer is organized hierarchically. The top layer is the primary memory, composed of cache and main memory, and provides fast access to data. Next is the second level of memory, consisting of slower disks and other devices. The third-level memory is the slowest storage device, such as optical discs and tapes.
Tapes are relatively inexpensive storage devices that can store large volumes of data, with the main drawback being that tapes are sequential access devices that must sequentially pass through all of the data without direct access to a particular location of the tape, so that tapes are not suitable for storing operational data or frequently accessed data, and tapes are primarily used for backup of phased operational data.
Disk supports direct access to a given address and is widely used in database applications. The data is stored on disk as a disk block. A disk block is a sequential sequence of bytes. is the unit of data read/write from disk. The block is distributed on concentric ring tracks of one or more platters. The size of the disk block can be set to a multiple of the sector size when the disk is initialized. Disk structure
The time to access the disk block consists of the following parts:
A) Seek time: The time used to move the head to the track where the desired block is located.
b) Rotation delay: the desired block is rotated to the head of the waiting time, its average time is the rotation of the half-circle required time, usually less than seek time.
c) Transfer time: The time the disk block was actually read or written when the head was positioned, that is, when the disk was rotated through the data block.
time of a complete input/output (IO) operation = Disk axis rotation time (rotation delay) + disk arm move time (seek time) + data transfer time.
The average experience for each of the three is: 0.004 seconds, 0.008 seconds, and 0.0005 seconds. So, the experience value of a full IO time is 0.0125 seconds, or 1/80 seconds.
The impact of disk structure on performance
(1) DBMS data must be manipulated in memory
(2) The unit of data transmission between the disk and main memory is block, if only one item on the block is needed, the entire block is transferred, and the read/write disk block is called an I/O operation.
(3) The time to read/write blocks varies depending on where the data resides:
Access time = Seek time + rotation delay + transfer time
9.2 Inexpensive Redundant array of disks (RAID)
A disk array is a form of organizing several disks together to improve performance and improve the reliability of the storage system.
Data partitioning is the distribution of data across multiple disks to improve performance.
Redundancy is used to improve reliability. Reliability is improved by adding redundant information rather than by simply copying the saved data. Redundant information is carefully organized to ensure that, in the event of a disk failure, redundant information can be used to reconstruct the contents on the failed disk. A disk array that combines data partitioning and redundancy becomes a redundant array of independent disks , referred to as RAID.
In data partitioning, the data is divided into segments of equal size and distributed across multiple disks, and the segment size is called the dividing unit. Data segments are usually distributed using a cyclic algorithm: If the disk array has d disks, then data segment I is written on the I mod D disk.
9.3 Disk space Management
Disk space Manager supports the concept of a page as a data unit, and provides commands for assigning and reclaiming and reading/writing pages. The disk block size is usually selected as the size of the page. And the page is stored as a disk block. This allows the I/O operation on one disk to complete a single page of read/write.
9.4 Buffer Manager
The buffer Manager is the software layer responsible for fetching pages from disk to main memory when necessary. It manages the available main memory by dividing the buffers into page sets, which are often referred to as buffer pools. The main memory pages in the buffer pool are called frames, and slots that hold pages (typically residing on disk or other level two storage)
In addition to the buffer pool itself, the buffer Manager maintains some bookkeeping information and two variables describing the frame: Pin-count and dirty, the number of times that the current page of a frame has been requested but not yet released, that is, the current number of users of the page, recorded in the Pin-count variable of that frame, The Boolean variable dirty indicates whether the page has been modified since it was read into the buffer pool from disk.
At the beginning, the pin-count of each frame is set to 0,dirty set to false. When the page is requested, the buffer does the following:
1. Check that the buffer pool contains the requested page, and if there is a page in the buffer pool, increase the Pin-count value of the page. If the buffer pool does not have this page, the buffer pool manager will read the pages in the buffer pool as follows:
A) Choose the replacement truth according to the substitution strategy and increase its pin-count;
b) If the dirty of the replacement frame is true, the page that holds the frame is written back to disk (that is, the copy of the disk page is overwritten by the contents of the frame)
c) Read the requested page into the replacement frame
2. Return the (main memory) address of the replacement frame to the requester.
* Buffer substitution Policy
Least recently used policy (LRU (least recently used) clock replaces first-in, first-out (FIFO), most recently used policy (MRU), stochastic policy
Storage data for database management systems: disks and files