- Preface: Why This Book Exists
- About the Author
- Who This Book Is For
- How to Use This Book
- Volume I: FOUNDATIONS & CORE CONCEPTS
- Chapter 1: PostgreSQL Architecture at a Glance
-
Chapter 2: Transaction Model & ACID Fundamentals
- Overview
- 2.1 What ACID Really Means in PostgreSQL
- 2.2 Transaction Lifecycle
- 2.3 The Write-Ahead Log (Preview)
- 2.4 Atomicity in Practice
- 2.5 Consistency: Business Logic’s Job
- 2.6 Real-World Scenario: Race Condition at 3 AM
- 2.7 Choosing Your Isolation Level
- Learning Objectives
- Exercises
- References & Diagnostics
- Bridge to Chapter 3 – Isolation Levels
-
Chapter 3: Isolation Levels & Snapshot Isolation
- Overview
- 3.1 The Four Isolation Levels
- 3.2 Read Committed (The Default Isolation Level)
- 3.3 Repeatable Read (Snapshot Isolation)
- 3.4 Serializable (SSI)
- 3.5 Decision Framework
- 3.6 Case Study: Payment System Gone Wrong
- 3.7 Practical Patterns and Anti-Patterns
- Exercises
- References & Diagnostics
- Bridge to Chapter 4 – MVCC
-
Chapter 4: MVCC – The Core Concept
- Overview
- 4.1 Why PostgreSQL Never Locks Readers
- 4.2 Transaction Identifiers (XID)
- 4.3 The 8KB Page: Where Tuples Live
- 4.4 Tuple Structure: xmin, xmax, and Hint Bits
- 4.5 The Visibility Algorithm
- 4.6 The Cost of MVCC
- 4.7 Vacuum, Pruning, and the Visibility Map
- 4.8 MVCC vs Other Concurrency Models
- 4.9 Practical Implications
- 4.10 Case Study: The Runaway Bloat Incident
- Learning Objectives
- Exercises
- References & Diagnostics
- Bridge to Chapter 5 – Storage & Pages
-
Chapter 5: Storage & Pages
- Overview
- 5.1 The Page: PostgreSQL’s Fundamental Unit
- 5.2 Page Internal Layout
- 5.3 Row Organization Within Pages: The ctid
- 5.4 Free Space Management: FSM and VM
- 5.5 TOAST: For Values That Don’t Fit
- 5.6 Files and Forks
- 5.7 Fillfactor and Page Packing Strategy
- 5.8 Asynchronous I/O in the Storage Stack (v18)
- 5.9 Case Study: The Page-Split Performance Cliff
- Exercises
- Bridge to Chapter 6
- References
-
Chapter 6: Buffer Cache – The Speed Layer
- 6.1 The Buffer Cache Concept
- 6.2 Shared Buffers and Double Buffering
- 6.3 Anatomy of a Buffer
- 6.4 Lifecycle: Hit, Miss, Read, Dirty
- 6.5 Eviction: Clock Sweep (LRU Approximation)
- 6.6 Dirty Pages, WAL, and Checkpoints
- 6.7 Measuring Cache Effectiveness
- 6.8 Sizing Strategy
- 6.9 Cache Warming
- 6.10 Operational Pitfalls
- 6.11 Case Study: The Oversized Cache
- 6.12 Diagnostics Checklist
- Exercises
- Conclusion
- Looking Ahead: Bridging to Volume 2
PostgreSQL Internals Mastery: A Comprehensive Guide
Volume I: Foundations & Core Concepts
"It’s 3 AM, your database just hit 500 connections, and everything has ground to a halt. Do you know why?"
Most database outages aren't mysterious—they are architectural. Stop treating PostgreSQL as a black box and start understanding the mechanical "why" behind the engine. PostgreSQL Internals Mastery: Volume I is a modular deep dive designed for senior engineers who need to bridge the gap between writing SQL and architecting high-performance systems. From the process-per-connection model to the groundbreaking Asynchronous I/O (AIO) features of PostgreSQL 18, learn the internals that separate database architects from administrators. Don't just tune knobs; understand the machine.
Minimum price
$19.00
$29.00
You pay
$29.00Author earns
$23.20Buying multiple copies for your team? See below for a discount!
About
About the Book
PostgreSQL Internals Mastery
Volume I: Foundations & Core Concepts
Stop treating PostgreSQL as a black box. Whether you are troubleshooting a production outage at 3 AM or designing a system to handle 10,000 transactions per second, you cannot optimize what you do not understand.
PostgreSQL Internals Mastery is a modular curriculum designed for senior engineers who need to understand the mechanical "why" behind database behavior. This first volume establishes the critical mental model required for all advanced performance tuning and architectural decision-making.
Why a Modular 5-Volume Series?
Traditional database books are often too shallow for experts or too academic for practitioners. By breaking this knowledge into five focused volumes, we allow you to:
- Master one layer at a time: Focus deeply on foundations before moving to query optimization or high availability.
- Just-in-time expertise: Buy only the volume you need for your current project or production bottleneck.
- Stay current: Receive free updates as PostgreSQL 18 and future versions evolve.
What You Will Learn in Volume I
- The Process Model: Why PostgreSQL uses processes instead of threads and how this impacts connection scaling.
- Memory Architecture: Mastering the crucial split between
shared_buffersand per-process memory likework_mem. - Physical Storage: How data lives in 8kB pages and how the system manages Free Space Maps (FSM) and Visibility Maps (VM).
- MVCC Foundations: The engine behind multi-version concurrency and how snapshots provide isolation without locking readers.
- PostgreSQL 18 Highlights: Get a first look at the new Asynchronous I/O (AIO) subsystem and how it overlaps disk I/O with computation.
Who This Book Is For
This series is written for database professionals who require an architectural understanding of the engine:
- Database Administrators responsible for reliability and optimization.
- Platform Engineers designing infrastructure at scale.
- Senior Backend Developers needing to understand how code interacts with internals.
- SREs troubleshooting complex performance stalls.
The Series Roadmap
- Volume I: Foundations & Core Concepts (Available Now)
- Volume II: Concurrency & Maintenance (Coming Soon)
- Volume III: Query Execution & Optimization
- Volume IV: Indexes & Advanced Topics
- Volume V: Case Studies & Real Scenarios
Team Discounts
Team Discounts
Get a team discount on this book!
Up to 3 members
- Minimum price
- $47.00
- Suggested price
- $72.00
Up to 5 members
- Minimum price
- $76.00
- Suggested price
- $116.00
Up to 10 members
- Minimum price
- $133.00
- Suggested price
- $203.00
Up to 15 members
- Minimum price
- $190.00
- Suggested price
- $290.00
Up to 25 members
- Minimum price
- $285.00
- Suggested price
- $435.00
Author
About the Author
Giovanni Martinez is a database professional with over a decade of experience navigating the complexities of high-concurrency environments. His journey began in the trenches as a Database Administrator (DBA), where he developed a deep respect for the mechanical realities of data storage and the "3 AM" outages that occur when those realities are ignored.
Over the last 10+ years, Giovanni has evolved his practice to specialize in DevOps and database management, focusing on how automated pipelines and intelligent tooling can prevent architectural failures before they reach production. He is the creator and lead maintainer of IQtoolkit.ai, an open-source project dedicated to bringing intelligent troubleshooting and management tools to the database ecosystem.
In PostgreSQL Internals Mastery, Giovanni distills his 10+ years of experience into a practical guide for engineers who want to move beyond "tuning blindly". By focusing on the engine at the process and memory level , he empowers readers to build systems that aren't just theoretically sound, but mechanically resilient.
Giovanni shares his knowledge through:
- The PostgreSQL Internals Mastery book series
- The IQtoolkit YouTube channel
- Technical writing and open-source contributions
Learn more at iqtoolkit.ai
Contents
Table of Contents
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.