Engineer Atlas
OverviewLearnInternalsModeling LabPlaygroundDatabase FinderRoadmapPracticeInterview
OverviewLearnInternalsModeling LabPlaygroundDatabase FinderRoadmapPracticeInterviewCheat SheetCompare
Database Engineering
  • Database Fundamentals
  • SQL
  • Relational Modeling
  • Normalization & Denormalization
  • Indexes
  • Query Execution & Optimization
  • Transactions
  • Concurrency & Isolation
  • PostgreSQL
  • Redis
  • NoSQL & Data Models
  • Vector Databases & Retrieval
  • Scaling
  • Distributed Databases
  • Caching
Database Internals
  • Overview
  • Build AtlasDB
  • Storage, Records & Pages
  • Index Internals
  • Buffer Management
  • WAL & Recovery
  • Transactions & MVCC Internals
  • LSM Trees
  • Query Engine
  • PostgreSQL & InnoDB Internals
  • Distributed Internals
  • Performance Internals
Database/Internals/PostgreSQL & InnoDB Internals
Database Internals

PostgreSQL & InnoDB Internals

The general mechanisms as two real engines implement them: heap tuples, xmin/xmax, shared buffers and VACUUM versus clustered primary keys, redo and undo logs.

Explains, from underneath:PostgreSQL
PostgreSQL Internals: Heap, Tuples, Shared Buffers, WAL, VACUUM
▶ interactive

PostgreSQL keeps every row version inside the table's own 8 KB heap pages, stamps each one with the transaction ids that created and deleted it, and pays for that simplicity with dead tuples, VACUUM and transaction-id wraparound — this is the general storage, MVCC and durability machinery as one engine actually built it.

InnoDB Internals: Clustered Index, Buffer Pool, Redo, Undo, Locks
▶ interactive

In InnoDB the table is a B+ tree ordered by primary key, secondary indexes store primary keys instead of addresses, old row versions live in undo logs rather than in the table, and durability rests on a circular redo log plus a doublewrite buffer — the same general mechanisms as PostgreSQL, with nearly every decision made the other way.

Physical Layouts Compared: Heap + Secondary Index vs Clustered Index
▶ interactive

Two ways to put a table on disk — rows in a heap addressed by indexes, or rows inside the primary-key tree addressed by key — and every difference in query cost, write amplification, index size and bulk-load speed between PostgreSQL and InnoDB follows from that one choice.

Engineer Atlas
GitHub·LinkedIn