Database Internals
Glossary
Every Database Internals term in plain words, with the module that teaches it. Inside modules, any word with a dotted underline explains itself.
Database Internals · 76 terms
- ACID
- The four guarantees of a transaction: Atomic (all or nothing), Consistent (rules hold), Isolated (concurrent transactions don't see each other's unfinished work) and Durable (committed changes survive crashes). Named by Härder and Reuter in 1983.
- Learn it in “Transactions and ACID” →
- Autocommit
- The default mode in which each SQL statement runs as its own transaction and commits immediately, unless you start a transaction explicitly with BEGIN.
- Learn it in “Transactions and ACID” →
- Autovacuum
- PostgreSQL's background process that runs VACUUM and ANALYZE automatically as tables change.
- Learn it in “MVCC” →
- B-tree
- A balanced tree of pages used for most database indexes: upper pages hold guide keys pointing to lower pages, and the leaves hold every key in sorted order, so any key is found in a few page reads.
- Think of it as: A multi-volume dictionary with guide words at the top of every page.
- Learn it in “B-trees” →
- Binary log (binlog)
- MySQL's log of committed changes, separate from InnoDB's redo log. Replicas read it and replay its events; it's also used for point-in-time recovery and change data capture.
- Learn it in “Replication under the hood” →
- Bloom filter
- A compact bit array that can say 'definitely not here' or 'maybe here' for a key, with a small rate of false 'maybes'. LSM trees use one per file to skip files that can't contain a key.
- Learn it in “LSM trees” →
- Buffer pool
- The area of memory where a database keeps copies of recently used pages, so most reads don't have to go to disk. PostgreSQL calls it shared buffers.
- Learn it in “The buffer pool” →
- Cache hit
- Finding the data you need already in memory, so no trip to storage is needed. A miss means reading it from disk or SSD, thousands of times slower.
- Learn it in “The buffer pool” →
- Cardinality estimate
- The planner's guess of how many rows a step of a query will produce. When it's far from reality, the planner can choose a plan that is thousands of times slower.
- Learn it in “Statistics and the optimiser” →
- Checkpoint
- A moment when a database has written all changed pages up to that point to disk, so crash recovery only needs to replay the log from there.
- Learn it in “Write-ahead logging and recovery” →
- Clustered index
- An index that holds the table's rows themselves, in key order, rather than pointers to them. In MySQL's InnoDB every table is stored as a clustered index on its primary key.
- Learn it in “Database engines compared” →
- Column store
- A database that stores each column's values together, so a query reading a few columns over many rows reads only those columns, and similar values compress well. Suited to analytics.
- Learn it in “Row stores and column stores” →
- Compaction
- Merging data files in the background, keeping only the newest version of each key and removing deleted entries, so reads check fewer files and old data stops using disk space.
- Learn it in “LSM trees” →
- Composite index
- An index on several columns, sorted by the first column, then the second, and so on. It helps queries that filter on its leading columns, like a phone book sorted by surname then first name.
- Learn it in “Using indexes well” →
- Consensus
- Getting a group of machines to agree on a sequence of values (such as log entries) even when some crash or messages are lost. Raft and Paxos are consensus protocols.
- Think of it as: Five friends booking a restaurant: it's decided once three say yes.
- Learn it in “Distributed SQL and consensus” →
- Covering index
- An index that contains every column a query needs, so the database can answer from the index alone (an index-only scan) without reading the table.
- Learn it in “Using indexes well” →
- ctid
- PostgreSQL's physical address for a row version: its page number and slot number, such as (12,4). It changes when the row is updated, so it can't be used as a permanent ID.
- Learn it in “Pages and rows” →
- Deadlock
- Two or more transactions each waiting for a lock another of them holds, so none can proceed. Databases detect the cycle and abort one of them.
- Think of it as: Two cooks: one holds the knife and wants the board, the other holds the board and wants the knife.
- Learn it in “Locks and deadlocks” →
- deadlock_timeout
- PostgreSQL setting: how long a transaction waits for a lock before the server checks whether it is part of a deadlock. Default 1 second. It doesn't abort anything by itself.
- Learn it in “Locks and deadlocks” →
- Dirty page
- A page in memory that has been changed but not yet written back to storage. It must be flushed before its memory can be reused.
- Learn it in “The buffer pool” →
- Dirty read
- Reading data written by another transaction that hasn't committed yet, and might still roll back.
- Learn it in “Isolation levels and anomalies” →
- Distributed SQL
- A relational database that spreads its data across many machines, replicates each piece with a consensus protocol, and still offers SQL and ACID transactions. Examples: Spanner, CockroachDB, TiDB, YugabyteDB.
- Learn it in “Distributed SQL and consensus” →
- Durability
- The promise that once a database says a change is saved, it survives crashes and power cuts, which means it has reached storage that doesn't forget, not just memory.
- Learn it in “Memory, SSDs and disks” →
- Eviction
- Removing a page from a full cache to make room for another. The eviction policy (such as LRU or clock sweep) decides which page goes.
- Learn it in “The buffer pool” →
- EXPLAIN
- A SQL command that shows the plan the database would use for a query, with estimated costs and row counts. EXPLAIN ANALYZE also runs the query and shows what actually happened.
- Learn it in “Parsing and planning” →
- fsync
- An operating system call that forces a file's buffered changes out to the storage device and waits until the device confirms, so they survive a crash.
- Learn it in “Memory, SSDs and disks” →
- Gap lock
- In MySQL InnoDB, a lock on the space between index entries that stops other transactions inserting there. Combined with a lock on the entry itself it's a next-key lock, used to prevent phantom rows.
- Learn it in “Locks and deadlocks” →
- GTID
- Global transaction identifier: a unique ID MySQL gives every committed transaction across a replication topology, so replicas can track what they've applied without log file positions.
- Learn it in “Replication under the hood” →
- Hash join
- A join method that builds an in-memory lookup table from one input, then streams the other input through it to find matches. Fast for large equality joins; slows down if the table spills to disk.
- Learn it in “Join algorithms” →
- Heap (table storage)
- Storing a table's rows in whichever page has room, in no particular order, as PostgreSQL does. Indexes then point to each row's page and slot.
- Learn it in “Pages and rows” →
- Hot standby
- A replica that accepts read-only queries while it keeps replaying the primary's log, ready to be promoted if the primary fails.
- Learn it in “Replication under the hood” →
- HOT update
- A heap-only tuple update in PostgreSQL: when no indexed column changes and the page has free space, the new row version stays on the same page and no new index entries are written.
- Learn it in “MVCC” →
- Hybrid logical clock (HLC)
- A timestamp made of a physical part (close to wall-clock time) and a logical counter that orders events with the same physical time. Used by CockroachDB.
- Learn it in “Distributed SQL and consensus” →
- Index
- A separate structure that lets a database find rows by a column's value without reading the whole table, like the index at the back of a book. It speeds up reads but adds work to every write.
- Learn it in “B-trees” →
- Inverted index
- An index that lists every word (or element) and, for each, the documents or rows that contain it, like the index at the back of a book. Used for full-text search, arrays and JSON.
- Learn it in “Hash, inverted and vector indexes” →
- Isolation level
- A setting that decides how much concurrent transactions may see of each other's work, and so which anomalies can happen: read uncommitted, read committed, repeatable read or serializable.
- Think of it as: How many bank counters share one ledger at once.
- Learn it in “Isolation levels and anomalies” →
- Join
- Combining rows from two tables that match on a condition, such as each order with its customer. Databases do it with nested loops, hash joins or merge joins.
- Learn it in “Join algorithms” →
- Lock
- A claim a transaction holds on a row, table or other object so that conflicting transactions must wait until it's released, usually at COMMIT or ROLLBACK.
- Think of it as: Holding the only knife in a kitchen.
- Learn it in “Locks and deadlocks” →
- Lock escalation
- Replacing many fine-grained locks (rows or pages) with one coarse lock (a table) to save memory, at the cost of blocking more of other transactions' work. SQL Server does this automatically.
- Learn it in “Locks and deadlocks” →
- Log sequence number (LSN)
- A position in the write-ahead log that only ever increases, used to order changes and to track how far recovery or a replica has got.
- Learn it in “Write-ahead logging and recovery” →
- Logical replication
- Replicating row-level changes (inserts, updates, deletes) for chosen tables, decoded from the log, using publish and subscribe. Works across major versions; doesn't copy schema changes.
- Learn it in “Replication under the hood” →
- LSM tree
- Log-structured merge-tree: a storage design that collects writes in memory, writes them out as sorted immutable files, and merges those files in the background. Very fast writes; reads may check several files.
- Learn it in “LSM trees” →
- Memtable
- The sorted in-memory table where an LSM tree collects new writes before flushing them to disk as a file.
- Learn it in “LSM trees” →
- MVCC (multi-version concurrency control)
- Keeping several versions of each row so that every transaction reads a consistent snapshot. Readers don't block writers and writers don't block readers; old versions are cleaned up later.
- Think of it as: Pinning the new timetable beside the old one instead of taking the old one down mid-read.
- Learn it in “MVCC” →
- Non-repeatable read
- Reading the same row twice in one transaction and getting different values, because another transaction changed it and committed in between.
- Learn it in “Isolation levels and anomalies” →
- OLTP
- Online transaction processing: workloads of many small, fast reads and writes of individual records, like placing orders or making payments. Analytics (OLAP) is the opposite: big scans and summaries.
- Learn it in “Row stores and column stores” →
- Page
- The fixed-size block a database reads and writes as a unit, usually 8 kB in PostgreSQL, 16 KB in MySQL's InnoDB and 4 KB in SQLite. Tables and indexes are stored as files of pages.
- Learn it in “Pages and rows” →
- Page split
- What happens when a B-tree page is full and a new key must go in: part of its keys move to a new page and the parent gets a pointer to it. A split of the root adds a level to the tree.
- Learn it in “B-trees” →
- Parser
- The part of a database that checks a SQL statement's syntax and turns the text into a tree structure the rest of the system can work with.
- Learn it in “What happens when you run a query” →
- Paxos
- Leslie Lamport's consensus protocol (published 1998), the foundation of many replicated systems, including Google's Spanner.
- Learn it in “Distributed SQL and consensus” →
- pg_stat_statements
- A PostgreSQL extension that tracks planning and execution statistics for every normalised SQL statement, so you can see which queries use the most time. It must be loaded via shared_preload_libraries.
- Learn it in “Capstone: the slow database” →
- Phantom read
- Running the same search twice in one transaction and getting a different set of rows, because another transaction inserted or deleted matching rows and committed.
- Learn it in “Isolation levels and anomalies” →
- Query plan
- The tree of steps a database chooses to run a query, such as which tables to scan, which indexes to use and how to join them. The same query can have many possible plans with very different costs.
- Learn it in “Parsing and planning” →
- Query planner
- The part of a database that works out how to run a query: it considers different ways (which indexes, which join order), estimates the cost of each and picks the cheapest. Also called the optimiser.
- Think of it as: A satnav comparing routes before you set off.
- Learn it in “Parsing and planning” →
- Raft
- A consensus protocol (Ongaro and Ousterhout, 2014) designed to be understandable: an elected leader copies log entries to followers, and an entry commits once a majority has it.
- Learn it in “Distributed SQL and consensus” →
- Row store
- A database that stores all the columns of a record together, so reading or writing one whole record touches one place. Suited to transactional work; PostgreSQL and MySQL are row stores.
- Learn it in “Row stores and column stores” →
- Selectivity
- The share of rows a condition matches. A selective condition matches few rows and suits an index; one matching most of the table is cheaper to answer with a full scan.
- Learn it in “Using indexes well” →
- Semi-synchronous replication
- MySQL mode where a commit waits until at least one replica has received the change and flushed it to its relay log (not applied it). Falls back to asynchronous if no replica answers in time.
- Learn it in “Replication under the hood” →
- Serializable snapshot isolation (SSI)
- Snapshot isolation plus tracking of which transactions read what others wrote; when a pattern could produce a non-serializable result, one transaction is aborted to be retried. PostgreSQL's serializable level since 9.1.
- Learn it in “Isolation levels and anomalies” →
- Slotted page
- The usual layout of a database page: a small array of pointers (slots) at the front and the rows packed from the back, so rows can move within the page while their slot numbers stay the same.
- Learn it in “Pages and rows” →
- Snapshot
- The view of the database a transaction or statement reads from: only changes committed before it was taken are visible, whatever happens afterwards.
- Learn it in “MVCC” →
- Snapshot isolation
- Each transaction reads from a consistent snapshot of the database taken when it starts, and a write fails if another transaction already changed the same row. Prevents dirty reads, non-repeatable reads and lost updates, but allows write skew.
- Learn it in “Isolation levels and anomalies” →
- SSTable
- Sorted string table: an immutable file of key-value pairs sorted by key, written when an LSM tree's memtable is flushed.
- Learn it in “LSM trees” →
- Streaming replication
- PostgreSQL's built-in physical replication: the primary sends write-ahead log records to standbys as they're generated, and each standby replays them to stay a byte-for-byte copy.
- Think of it as: Chess by post: send each move, and the other board stays identical.
- Learn it in “Replication under the hood” →
- synchronous_commit
- PostgreSQL setting for when a commit is reported as done: off, local (flushed locally), remote_write, on or remote_apply (the standby has written, flushed or applied it). The remote levels need a synchronous standby to be configured.
- Learn it in “Replication under the hood” →
- Table statistics
- Summaries a database keeps about its data, such as row counts, distinct values and common values with their frequencies, which the planner uses to estimate how many rows each step will produce.
- Learn it in “Statistics and the optimiser” →
- Transaction
- A group of database changes treated as one unit: either all of them take effect (COMMIT) or none do (ROLLBACK), even if something fails halfway.
- Think of it as: A contract: either everyone is bound by it or no one is.
- Learn it in “Transactions and ACID” →
- Transaction ID wraparound
- PostgreSQL transaction IDs are 32-bit and compared on a circle, so a row left unfrozen for more than about 2 billion transactions would appear to be in the future and vanish. VACUUM's freezing prevents it.
- Learn it in “MVCC” →
- TrueTime
- Google Spanner's clock API: it returns the current time as an interval guaranteed to contain the true time, using GPS and atomic clocks. Spanner waits out the uncertainty before making a commit visible.
- Learn it in “Distributed SQL and consensus” →
- Two-phase locking (2PL)
- A rule for locking: a transaction takes all its locks (growing phase) before releasing any (shrinking phase). It guarantees a serializable result. Strict 2PL holds write locks until commit.
- Learn it in “Locks and deadlocks” →
- Undo log
- A record of the old values of changed rows, kept so a transaction can be rolled back and so readers can rebuild earlier versions for their snapshot. Used by InnoDB and Oracle for MVCC.
- Learn it in “MVCC” →
- VACUUM (PostgreSQL)
- The PostgreSQL command that removes dead row versions no transaction can still see, marks their space reusable and freezes old rows against transaction ID wraparound. It doesn't normally shrink the table file.
- Learn it in “MVCC” →
- Vector index
- An index for finding the stored vectors (lists of numbers that capture meaning) closest to a query vector. Approximate ones such as HNSW trade a little accuracy for much faster search.
- Learn it in “Hash, inverted and vector indexes” →
- Write skew
- Two concurrent transactions read overlapping data, then each updates a different row based on what it read, together breaking a rule neither would break alone (for example, both on-call doctors going off call).
- Learn it in “Isolation levels and anomalies” →
- Write-ahead log (WAL)
- A sequential log on disk where a database records every change before changing the data files. After a crash, replaying it restores committed work.
- Think of it as: A shop's day book, written before the ledgers are updated.
- Learn it in “Write-ahead logging and recovery” →
- xmin and xmax
- Hidden columns on every PostgreSQL row version: xmin is the ID of the transaction that created it, xmax the ID of the transaction that deleted or replaced it (0 if none). Together with a snapshot they decide which version a transaction sees.
- Learn it in “MVCC” →
A
B
C
D
E
F
G
H
I
J
L
M
N
O
P
Q
R
S
T
U
V
W
X
General terms · shared by every track
- ACID
- Four guarantees for transactions: Atomic (all or nothing), Consistent (rules hold), Isolated (concurrent work doesn't interfere), Durable (once done, it stays done).
- Learn it in “ACID on object storage” →
- Atomic
- All or nothing. An atomic change either happens completely or not at all, and nobody ever sees it half done.
- Think of it as: Handing over a sealed envelope: the other person has it or doesn't. There's no half-handed envelope.
- Learn it in “Object storage: the ground floor” →
- Batch processing
- Processing data in scheduled chunks, such as every night or every hour.
- Learn it in “Getting data in” →
- CSV
- Comma-separated values: plain text, one row per line. Easy to read, slow and large for analytics, and no schema.
- Learn it in “Rows vs columns: file formats” →
- Idempotent
- Safe to run twice: running the job again gives the same result instead of duplicating data.
- Learn it in “Medallion architecture” →
- JSON
- A text format of nested key-value objects, like {"id": 7}. Common for app events and APIs, and used by Delta's transaction log.
- Learn it in “Rows vs columns: file formats” →
- Metadata
- Data about data: which files exist, their schema, sizes and statistics. Engines read metadata first to plan work.
- Learn it in “What makes a table a table” →
- Schema
- The structure of a table: its column names and types, such as order_id: long, amount: decimal.
- Learn it in “Schema evolution & enforcement” →
- SQL
- The standard language for querying tables: SELECT … FROM … WHERE …
- Learn it in “Hands-on: query in your browser” →
- Streaming
- Processing data continuously as it arrives, within seconds or minutes.
- Learn it in “Getting data in” →
- Transaction
- A group of changes that succeeds or fails as one unit.
- Think of it as: A money transfer: debit one account and credit the other, or do neither.
- Learn it in “ACID on object storage” →
A
B
C
I
J
M
S
T