1 / 9

The very Essentials of Disk and Buffer Management

The very Essentials of Disk and Buffer Management. Disks and Main Memory. DBMS stores information on (“hard”) disks. This has major implications for DBMS design! READ: transfer data from disk to main memory (RAM). WRITE : transfer data from RAM to disk.

jhiltner
Télécharger la présentation

The very Essentials of Disk and Buffer Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The very Essentials of Disk and Buffer Management

  2. Disks and Main Memory • DBMS stores information on (“hard”) disks. • This has major implications for DBMS design! • READ:transfer data from disk to main memory (RAM). • WRITE: transfer data from RAM to disk. • Both are high-cost operations, relative to in-memory operations, so must be planned carefully! • Why disks? • Cheaper than Main Memory • Higher Capacity • Main Memory is volatile • Typical storage hierarchy: • Main memory (RAM) for currently used data. • Disk for the main database (secondary storage). • Tapes for archiving older versions of the data (tertiary storage).

  3. Disks • Secondary storage device of choice. • Data is stored and retrieved in units called disk blocks or pages. • Time to read/write data block: • 2- 20 msec for random data block (main factor is seek time) • If blocks are sequentially on disk, each additional block only 1 msec • Compare main memory access: in nanoseconds

  4. Architecture Upper Layer Secondary Storage (stable) Cache/Buffer Manager Buffer (volatile)

  5. Page Formats: Variable Length Records Rid = (i,N) • Record id (rid)= internal identifier of a record: <page id, slot #>. • Can move records on page without changing rid; Page i Rid = (i,2) Rid = (i,1) 20 16 N 24 Pointer to start of free space N . . . 2 1 # slots Record Length SLOT DIRECTORY

  6. Buffer Management in a DBMS DB Page Requests from Higher Levels • Data must be in RAM for DBMS to operate on it! • Table of <frame#, pageid> pairs is maintained. • Some more information about each page in buffer is maintained BUFFER POOL disk page free frame MAIN MEMORY DISK choice of frame dictated by replacement policy

  7. When a Page is Requested ... • If requested page is not in pool: • If there is an empty frame • Choose empty frame • Else (no empty frame) • Choose a frame for replacement • If frame is dirty (page was modified), write it to disk • Read requested page into chosen frame • Pin the new page and return its address.

  8. More on Buffer Management • After operation has finished • Requestor unpins pages • Set dirty bit if page has been modified: • Page in pool may be requested many times: pin count • Page is requested: increase pin count • Unpin: decrease pin count • Frame is chosen for replacement by a replacement policy: • Only unpinned page can be chosen (pin count = 0) • Least-recently-used (LRU), Clock, MRU etc. • Pages are a common lock granularity for the lock manager

  9. DBMS vs. OS File System OS does disk space & buffer mgmt: why not let OS manage these tasks? • Differences in OS support: portability issues • Some limitations, e.g., files can’t span disks. • Buffer management in DBMS requires ability to: • pin a page in buffer pool, force a page to disk (important for implementing CC & recovery), • adjust replacement policy, and pre-fetch pages based on access patterns in typical DB operations.

More Related