You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PostgreSQL uses slotted pages internally. Tuples grow backward from the end of the page while the slot directory grows forward from the header. This allows efficient deletes (just mark a slot as deleted) without physically shifting tuple data.
Why B+ Tree (not B-Tree)?
In a classic B-tree, data can live in internal AND leaf nodes. But when you want range scans (e.g., WHERE age BETWEEN 20 AND 30), you'd have to do a complex in-order traversal. B+ trees keep ALL data in leaf nodes and link leaves together — so range scans simply walk the leaf chain. PostgreSQL uses B+ trees for exactly this reason.
Why LRU Buffer Pool?
Disks are ~100,000× slower than RAM. By caching recently-accessed pages in memory and only flushing to disk when necessary, we avoid redundant I/O. LRU (Least Recently Used) evicts the page that hasn't been accessed for the longest time — a simple but effective policy used by real databases.
Why Strategy-Based Query Execution?
Not every query benefits from an index. A SELECT * returns all rows anyway — an index adds overhead. The query engine checks: "is there an index on the column in the WHERE clause?" If yes, use IndexScan. If no, use SeqScan. This is a simplified version of what PostgreSQL's query planner does.