BUFFER MANAGENMENT ~Sakshi kanthale Roll no-SY1124
PRESENTATION CONTENTS:- 1. WHAT IS DATABASE BUFFERING? 2. HOW BUFFER MANAEGNMENT WORKS? 3. TYPES OF BUFFER MANAGNMENT 4. BUFFER MANAGNMENT STRATEGIES 5. IMPORTANCE OF BUFFERING 6. CHALLENGES IN BUFFERING 7. BEST PRACTISES
WHAT IS DATABASE BUFFERING? WHAT IS DATABASE BUFFERING? Database buffering is a technique to improve database performance. It involves temporarily storing data in memory for faster access. It creates a bridge between fast memory and slow disk storage. Implements a "buffer pool" to manage multiple memory buffers. Acts as an intermediary layer for data transfer.
HOW BUFFER MANAGENMENT WORKS Buffer Pool Organization - Divides memory into fixed-size pages or frames Maintains a directory of buffers and their contents Page Replacement Algorithms - Implements strategies like LRU (Least Recently Used) or Clock algorithm Decides which pages to evict when the buffer pool is full Pinning and Unpinning - Pins pages in memory during active use to prevent eviction Unpins pages when operations are complete, allowing for potential replacement Dirty Page Management - Tracks modified ("dirty") pages in memory Writes dirty pages back to disk periodically or when evicted Prefetching and Write-behind - Anticipates future data needs and loads pages proactively - Delays writing changes to disk to optimize I/O operations
BUFFER POOL 5
TYPES OF BUFFER MANAGENMENT 6 Data Buffers Store actual data pages from tables Caches frequently accessed or recently used data Index Buffers Hold pages containing index structures Speeds up index-based queries and lookups Log Buffers Store transaction log information before writing to disk Crucial for ensuring ACID properties, especially durability Sort Buffers Temporary storage for sorting operations Improves performance of ORDER BY and GROUP BY operations Join Buffers Used for caching intermediate results during join operations Enhances efficiency of complex queries involving multiple tables
BUFFER MANAGENMENT STRATEGIES 1. Buffer Pool Partitioning Divides buffer pool into multiple areas for different purposes e.g., separate partitions for indexes, data, and temporary operations 2. Prefetching Proactively loads data into buffers based on predicted access patterns Sequential prefetching for table scans Index prefetching for index-based queries 3. Write Strategies Write-through : Immediately writes changes to disk Write-behind (or write-back) : Delays writing to disk to optimize I/O 4. Buffer Pinning and Unpinning Pins frequently used pages in memory to prevent eviction Unpins pages when no longer needed 5. Dirty Page Management Tracks modified pages and schedules them for writing to disk Implements strategies to balance memory usage and durability requirements
IMPORTANCE OF BUFFER MANAGENMENT 8 Speed: Getting data from the buffer is much faster than from the hard drive. Efficiency: The computer doesn't have to keep going back to the hard drive for data it uses often. Better Performance: Your database can handle more work in less time.
CHALLENGES IN BUFFER MANAGEMNET 1. Limited Buffer Size Too small: frequent disk access slows performance Too large: wastes memory needed for other operations 2. Concurrency Control Risk of data inconsistency or conflicts 3. Buffer Thrashing Avoiding constant swapping of pages in and out of the buffer Occurs when working set is larger than the buffer pool Results in severe performance degradation 9
BEST PRACTISES FOR BUFFERING Be Smart About What to Keep Use Multiple Buffer Pools Optimize Buffer Pool Size Implement Effective Concurrency Control 10