Download presentation
Presentation is loading. Please wait.
Published byJunior Corcoran Modified over 10 years ago
1
Introduction to Database Systems1 Buffer Management Storage Technology: Topic 2
2
Introduction to Database Systems2 Effective Use of Main Memory v Memory is used as a cache for data on disk v Issue: Granularity? v Issue: Updates? v Issue: Replacement? v Issue: Efficient lookup? v Issue: Concurrency?
3
Introduction to Database Systems3 Buffer Management in a DBMS v Data must be in RAM for DBMS to operate on it! v Table of pairs is maintained. DB MAIN MEMORY DISK disk page free frame Page Requests from Higher Levels BUFFER POOL choice of frame dictated by replacement policy
4
Introduction to Database Systems4 When a Page is Requested... ¬ If the page is in the BP, go to 4 þ Why would this happen? can it be encouraged? Choose a frame to read into. þ How does one do this? ® Read page into chosen frame. ¯ Pin the page and return to caller. þ To avoid thrashing ° The caller eventually unpins the page þ Has the page been modified?
5
Introduction to Database Systems5 Picking a Frame v If there is a free frame, use it v Use the page replacement policy to find a victim frame. v If victim frame is dirty, write it to disk (look at the next slide -- Update policy)
6
Introduction to Database Systems6 Buffer Manager Details v Granularity : disk page size (4K, 8K) v Updates : write-back not write-through v Efficient lookup : hash table mapping pages to frames (hash function applied to what?) v Concurrency : what if several pages are requested at the same time? v What if the same page is requested multiply?
7
Introduction to Database Systems7 Buffer Replacement Policy v Optimal policy needs to know future accesses. v At each stage, the victim should be the page used furthest into the future. v Practical repl. policies use a crystal ball. v Driven by knowledge of application behavior. v Least-recently-used (LRU), Clock, MRU, etc. v Pre-fetch, delayed-write, and other smarts.
8
Introduction to Database Systems8 DBMS vs. OS File System OS does disk space & buffer mgmt: why not let OS manage these tasks? v Differences in OS support: portability issues v Some limitations, e.g., files cant span disks. v Buffer management in DBMS requires: –pinning a page in buffer pool, forcing a page to disk (important for implementing CC & recovery) –adjust replacement policy and pre-fetch pages based on access patterns in typical DB operations
9
Introduction to Database Systems9 Summary v Buffer manager brings pages into RAM. –Page stays in RAM until released by requestor. –Written to disk when frame chosen for replacement (which is sometime after requestor releases the page). –Choice of frame to replace based on replacement policy. –Tries to pre-fetch several pages at a time. v DBMS vs. OS File Support –DBMS needs features not found in many OSs,
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.