The DBMS can almost always manage memory better than the OS.
<aside> 💡 Two types of contol we care about
Memory region organized as an array of fixed-size pages.
An array entry is called a frame.
When the DBMS requests a page, an exact copy is placed into one of these frames.
The page table keeps track of pages that are currently in memory.
Also maintains additional meta-data per page:
<aside> 💡 Locks
<aside> 💡 Latches
Locks | Latches | |
---|---|---|
Separate … | User Transaction | Threads |
Protect … | Database Contents | In-Memory Data Structures |
During … | Entire Txns | Critical Sections |
Modes … | S, X, Update, Intention | R, W |
Deadlock | Detection & Resolution | Avoidance |
… by … | Waits-fir, Timeout, Aborts | Coding Discipline |
Kept in … | Lock Manager | Protected Data Structure |
Page directory
the mapping from page ids to page locations in the database files.
All changes must be recorded on disk to allow the DBMS to find on restart.
Page table
the mapping from page ids to a copy of the page in buffer pool frames.
This is an in-memory data structure that does not need to be stored on disk.
Care about thread-safety, not scalability
Global Policies:
Make decisions for all active txns.
Local Policies
Allocate frames to a specific txn without considering the behavior of concurrent txns. Still need to support sharing pages.
The DBMS not always have a single buffer pool for the entire system