- Introduction
-
Part I — PostgreSQL Internals
-
1. Storage and Memory Internals
- 1.1 Heap File Layout
- 1.2 TOAST
- 1.3 Visibility Map & Free Space Map
- 1.4 Buffer Pool
- 1.5 WAL Internals
- 1.6 Full-Page Writes
-
2. Indexing Deep Dive
- 2.1 B-Tree and B+ Tree
- 2.2 Index-Only Scans and Covering Indexes
- 2.3 Hash Indexes
-
1. Storage and Memory Internals
Database Engine Level Thinking
Building a mental model of PostgreSQL internals — written while learning
Stop only using databases — start understanding them. A living study of PostgreSQL internals for backend engineers: how pages, indexes, and WAL actually work, written clearly while learning, not after mastery.
Minimum price
Free!
$1.00
You pay
Author earns
About
About the Book
This book is for backend engineers who already ship systems people depend on — who can write SQL, know what an index is for, and have watched production surprise them anyway.
It is not a tutorial from an expert looking back. It is written alongside the learning: one mechanism at a time, rewritten carefully enough to be a lasting reference. Documentation tells you what a parameter does. This book tries to tell you what is happening underneath such that the parameter needs to exist at all.
The current edition covers PostgreSQL storage and memory (heap pages, TOAST, visibility and free-space maps, the buffer pool, WAL, full-page writes) and indexing (B-trees, leaf splits, HOT updates, index-only scans, covering indexes, and hash indexes). More chapters will follow as the study continues.
If something here is wrong or incomplete, that is expected of a living draft. Correct it, and keep going. That is the point.
Feedback
Author
About the Author
I’m Kareem Ashraf, a backend software engineer.
I started caring about databases for a concrete reason: I worked on a service that acted as a query builder, and the hard part was not writing SQL — it was making it fast. Indexing and vacuum helped, until they did not. I hit a ceiling where the usual knobs were not enough. To go further I had to understand the internals and the trade-offs behind them.
So I studied — books, articles, tutorials, and hands-on notes from running and breaking real systems. Database Engine-Level Thinking is that journey written down: what I have learned so far, what I am still learning, and how the internals connect to optimisation that shows up in production.
Not trivia for its own sake — mechanisms with a use case, for backend engineers who are tired of guessing.
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.
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 $15 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.