Database Concepts

PostgreSQL, SQL, MongoDB, and DynamoDB — core concepts explained in depth.

Sort

Query Techniques

62
MongoDB

MongoDB Search and Vector Search: $search, $vectorSearch, and RAG Retrieval

MongoDB Search and MongoDB Vector Search (formerly Atlas Search / Atlas Vector Search) are Lucene-backed full-text and ANN/HNSW semantic search served by a separate mongot process synchronized via change streams — eventually consistent, memory-bound by the vector index size, and since MongoDB 8.2 available self-managed rather than only on Atlas, though with a materially narrower feature set than the managed platform.

66
MongoDB

MongoDB Aggregation Pipelines: Stages, Expressions, and Accumulators

An aggregation pipeline is a bash-style chain of stages over a stream of documents, and the skill is knowing which stages shrink the stream ($match, $group), which grow it ($unwind), and which merely reshape it ($project, $sort) — then ordering them so field-path expressions, accumulators, and a well-labeled $group _id produce the right number instead of a plausible one.

73
MongoDB

MongoDB Querying: Conditionals, Projections, and Cursors

Query MongoDB with find — projections, $ conditionals, $in/$or/$not, and the type-specific traps around null, arrays, and embedded documents — then drive the resulting cursor with limit, skip, and sort without falling into large-skip pagination.

109
SQL

Merging Records: The MERGE Statement and MySQL's Upsert Alternative

How MERGE conditionally updates, deletes, or inserts rows in one atomic statement across matched/unmatched source rows, why PostgreSQL had no MERGE at all until version 15 (2022) — two years after this book's 2nd edition — and why MySQL's INSERT ... ON DUPLICATE KEY UPDATE can insert-or-update but never delete in the same statement.

125
SQL

Stacking Rowsets: UNION, UNION ALL, and the Wider Set-Operator Family

How UNION ALL vertically stacks rowsets and UNION does the same while deduplicating (at the cost of a sort), why column count and type compatibility rules are identical across PostgreSQL, MySQL, and SQL Server, and how MySQL 8.0.31 (2022) closed its long-standing INTERSECT/EXCEPT gap — while SQL Server still has no ALL variant for either.

127
SQL

Conditional Sorting: NULLs and Data-Dependent Order in SQL

How to sort NULLs to a specific position independent of the non-NULL order, and how to sort by a key that depends on another column's value — and why the book's claim that PostgreSQL needs the same workaround as MySQL/SQL Server for NULL sorting is simply wrong (PostgreSQL has had native NULLS FIRST/LAST since 2008).

128
SQL

Handling NULLs and Pattern Matching in SQL

How IS NULL/IS NOT NULL and COALESCE handle missing data portably across databases, how LIKE's % and _ wildcards match partial text, and the case-sensitivity and indexing gotchas (leading vs trailing wildcards, pg_trgm) that differ across PostgreSQL, MySQL, and SQL Server.

129
SQL

Limiting and Randomly Sampling Query Results

How PostgreSQL, MySQL, and SQL Server each cap the number of rows a query returns (LIMIT, TOP, and the ANSI FETCH FIRST standard MySQL doesn't support), how to randomize the sample before capping it, and why TABLESAMPLE beats ORDER BY RANDOM() for large tables.

Joins & Set Operations

99
SQL

Deleting Records Referenced from Another Table

Removing rows identified by their relationship to a second table — the IN/EXISTS subquery form, the NOT IN null trap on the inverse case, and the three incompatible vendor join-DELETE syntaxes.

112
SQL

Deleting Duplicate Records

How to arbitrarily keep one row per duplicate group and delete the rest with MIN(id) NOT IN, why MySQL still rejects a DELETE subquery that reads its own target table, and how ROW_NUMBER() over a CTE offers a more portable — though not identically-syntaxed — alternative across PostgreSQL, MySQL, and SQL Server.

113
SQL

Returning Missing Data from Both Tables with FULL OUTER JOIN

How to return unmatched rows from both sides of a join at once — departments with no employees and employees with no department, simultaneously — using FULL OUTER JOIN where it's supported, or a UNION of a LEFT and RIGHT outer join where it isn't (MySQL, and Oracle's proprietary (+) syntax).

115
SQL

Performing Outer Joins When Using Aggregates

How to correctly sum a column across every row of a table when a second, joined table only has matching rows for some of them — outer join instead of inner join, and let the CASE expression treat a NULL match as zero instead of skipping the row.

117
SQL

Performing Joins When Using Aggregates: Avoiding Fan-Out

Why joining before aggregating can silently inflate a SUM by counting a duplicated row more than once, and how to fix it with SUM(DISTINCT ...), pre-aggregating in a subquery before the join, or a window function on DB2/Oracle/SQL Server.

119
SQL

Identifying and Avoiding Cartesian Products

How a missing or incomplete join condition silently multiplies row counts instead of erroring out, why the resulting row count is always the product of the input cardinalities, and why explicit ANSI JOIN syntax catches the mistake at parse time where old-style comma joins let it run.

121
SQL

Comparing Two Tables for Equality (Cardinality and Values)

Use a symmetric set difference (EXCEPT/MINUS, or a correlated-subquery fallback) to prove two tables or views hold exactly the same rows, duplicates included.

123
SQL

Anti-Joins and Optional Joins: Finding Missing Rows and Adding Data Without Losing Rows

How LEFT JOIN + IS NULL (an anti-join) finds rows in one table with no match in another, how the same LEFT JOIN mechanism — or a scalar subquery in the SELECT list — adds optional data to an already-correct query without dropping rows, and why MySQL and PostgreSQL both recognize the anti-join pattern and stop scanning early instead of evaluating it as a naive join-then-filter.

Window Functions & Analytics

81
SQL

SQL: Window Function Ranking and Row Navigation

Use LEAD and LAG to read or shift a neighboring row's value, and RANK, DENSE_RANK, and ROW_NUMBER to assign ordinal positions with three different tie-handling rules.

82
SQL

Subtotals and Grand Totals: ROLLUP, CUBE, and GROUPING SETS

Produce subtotal and grand-total rows alongside detail rows in a single query — ROLLUP for a hierarchy, CUBE or GROUPING SETS for every combination of grouping columns — and use GROUPING() to tell a manufactured subtotal NULL apart from a real one, with MySQL Server still limited to ROLLUP alone.

83
SQL

Bucketing Data and Text Histograms

Splitting a result set into fixed-size buckets with ROW_NUMBER and CEILING versus a fixed number of buckets with NTILE, then rendering the distribution as a horizontal or vertical text histogram.

84
SQL

Pagination, Top-N with Ties, and Extremes per Group

A whole family of "which rows, and how many" problems past a plain LIMIT — paginating through results, sampling every Nth row, handling ties in a top-N query, and finding the highest/lowest value per group.

85
SQL

Differences Between Adjacent Rows and Filling Gaps

Compare a row to its neighbor inside an ordered partition with LEAD/LAG, and carry the last known value forward across NULL gaps with LAST_VALUE or a counted-group FIRST_VALUE — plus the real portability gaps in offset expressions and IGNORE NULLS.

86
SQL

Gaps and Islands: Consecutive Values and Sequence Generation

Find contiguous runs in a sparse numeric sequence, collapse each run to its start and end, and generate the dense sequence that reveals what's missing.

93
SQL

Mode, Median, and Outlier Detection with MAD

Computing the mode, the median, and a median-absolute-deviation outlier score in SQL, and why PostgreSQL, MySQL, and SQL Server each need a different query to do it.

94
SQL

Running Totals, Running Products, and Moving Aggregates

One window-function shape — SUM/AVG OVER with an ORDER BY and a frame — solves running totals, running products, moving averages, and resettable accumulators, including why a running product has no native aggregate and why the default RANGE frame is a tie-related footgun.

95
SQL

Multi-Partition and Moving-Range Window Aggregations

Computing several different partition-level aggregates side by side in one query, and moving windows framed symmetrically or by value range rather than by trailing row count.

Date & Time

87
SQL

Date Gaps, Missing Dates, and Overlapping Ranges

Reason about dates as intervals rather than points: measure the gap to the next row with LEAD, fill holes in a date sequence with a generated calendar, and detect colliding date ranges with a self-join condition or PostgreSQL's native range types.

88
SQL

Weekday Search in Date Ranges

Finding every occurrence of a weekday in a year and the first/last occurrence in a month, and navigating the incompatible weekday-numbering conventions across PostgreSQL, MySQL, and SQL Server.

89
SQL

Generating Calendars and Quarter Boundaries

Manufacturing date rows that no table stores — a full calendar grid, or a fiscal quarter's start and end dates — with generate_series, recursive CTEs, and SQL Server 2022's numeric-only GENERATE_SERIES.

90
SQL

Date Truncation and Date Parts

Decomposing a date into leap-year status, days-in-year, individual units of time, and month boundaries — and where EOMONTH, LAST_DAY, and DATETRUNC have replaced the manual arithmetic.

91
SQL

Business Days and Weekday Counts in a Date Range

Counting working days between two dates and tallying weekday occurrences across a year — generating one row per day with generate_series, recursive CTEs, or a numbers table, and avoiding SQL Server's session-dependent @@DATEFIRST weekday numbering.

92
SQL

Date Arithmetic: Shifting Dates and Measuring Intervals

Adding intervals to dates and measuring the distance between two dates in days, months, years, or sub-day units — and why SQL Server counts calendar boundaries where PostgreSQL and MySQL truncate elapsed units.

String & Text Processing

Advanced Query Patterns

Document Model

1
CouchDB

CouchDB Replication and the Changes API

Covers CouchDB's multi-master replication model (no designated primary, any node accepts writes directly, with true bidirectional sync built from two unidirectional replication jobs), ad hoc vs. continuous replication and the _replicator database for durable jobs, how replication conflicts are detected and surfaced via a deterministic winner algorithm and the _conflicts field, and the Changes API's polling/long-polling/continuous/eventsource feed types with filter functions and _selector filtering, plus a book-vs-today check confirming CouchDB 3.x clustering maturity and PouchDB's active status as Apache PouchDB.

2
CouchDB

CouchDB Views and Map/Reduce Queries

CouchDB has no ad-hoc query language for anything beyond simple key lookups: every non-trivial query is a pre-defined map/reduce view, written in JavaScript with emit(), saved into a design document, and materialized incrementally into a B-tree index as documents change. Since CouchDB 2.0 (2016), Mango's declarative _find queries cover simple lookups without hand-written JavaScript, but they are themselves built on the same MapReduce view infrastructure and still can't replace views for aggregation or fan-out patterns.

8
CouchDB

The Document Model: HTTP-Only Access and Revision-Based MVCC

CouchDB exposes documents exclusively over HTTP/REST — no wire protocol, no binary driver, every operation is a curl-shaped request — and replaces locking with revision-based MVCC: a stale _rev gets a 409 on a single node, but across replicas both concurrent writes succeed and the resulting conflict is detected and merged by the application, never by the database.

63
MongoDB

MongoDB Time Series Collections: Bucketing, Granularity, and What You Give Up

A time series collection is a MongoDB 5.0 collection type that turns one-document-per-reading into compressed columnar buckets keyed by an immutable metaField plus a rounded time window, buying real storage and query wins for append-only measurement data at the cost of a long and specific list of restrictions: metaField-only updates, no unique or text indexes, no change streams, no writes in transactions, and a metaField choice you cannot change later.

65
MongoDB

MongoDB Schema Design: Patterns, Embedding vs. Referencing, and Cardinality

MongoDB schema design starts from the queries rather than the entities, so the chapter's method is to establish constraints, access patterns, relation types, and cardinality first, then reach for a named pattern (Bucket, Subset, Outlier, Extended Reference) and settle the embed-or-reference question per field — with an honest closing section on the joins MongoDB was never designed to do.

74
MongoDB

MongoDB Writes: Inserts, Update Operators, Upserts, and Deletes

MongoDB's write path is insertOne/insertMany, deleteOne/deleteMany/drop, and updateOne/updateMany/replaceOne — and the decisions that actually bite are replacement vs. $-operators, ordered vs. unordered batches, and whether upsert quietly turns a failed match into a brand-new document.

75
MongoDB

The Document Model: Documents, Collections, and ObjectIds

MongoDB swaps rows and tables for documents and dynamically-schemaed collections, using embedded documents and arrays where a relational model would JOIN, and a 12-byte ObjectId (4-byte timestamp, 5 random bytes, 3-byte counter) to mint unique _id values with no cross-server coordination.

Indexing & Performance

Graph Fundamentals

Wide-Column Fundamentals

3
HBase

HBase Architecture: HMaster, Regions, RegionServers, and MapReduce Integration

How an HBase cluster actually holds a table together underneath the API: regions as contiguous, non-overlapping row-key ranges served by RegionServers, HMaster handling region assignment and failover (not the read/write path itself), HDFS as the durable storage layer every RegionServer writes StoreFiles and WALs through, ZooKeeper coordinating master election and the hbase:meta bootstrap location, and hbase:meta itself as an ordinary, splittable table that maps row keys to owning regions and servers — plus how MapReduce parallelizes batch jobs one map task per region via TableInputFormat/TableOutputFormat, with book-vs-today notes on size-aware split policies, the rise of Spark-on-HBase for new analytics work, and confirmation that HBase remains actively released and maintained.

4
HBase

HBase's Data Model, CRUD, and Table Administration

HBase's sparse, distributed, sorted multidimensional map (row key, column family, column qualifier, timestamp/version to a cell value), CRUD and table administration through the HBase shell (create, put, get, scan, disable, alter, enable), and an explicit comparison to Cassandra's wide-column model: shared Bigtable-paper lineage and column-family vocabulary, but master-coordinated writes over HDFS and ZooKeeper with row-level strong consistency versus Cassandra's leaderless, tunable-consistency architecture, plus a book-vs-today check on HBase's current maintenance status and shifting market position against Cassandra/ScyllaDB and managed Bigtable/DynamoDB.

Transactions & Consistency

High Availability

Scaling & Sharding

Fundamentals

Data Modeling

15
DynamoDB

DynamoDB Additional Strategies: Uniqueness, Sequential IDs, and Pagination

DynamoDB has no unique-constraint or auto-increment feature outside the primary key, so uniqueness on a second attribute needs a marker item plus TransactWriteItems, and sequential IDs need an atomic-counter UpdateItem followed by a PutItem — and pagination is cursor-based via LastEvaluatedKey/ExclusiveStartKey rather than SQL's OFFSET/LIMIT, a distinction that still holds in AWS's current docs, though the TransactWriteItems action limit has since grown from 25 to 100.

16
DynamoDB

DynamoDB Sorting Strategies: ScanIndexForward, Zero-Padding, and Hierarchical Sort Keys

DynamoDB orders every Query result by the sort key's B-tree order — ascending by default, reversed with ScanIndexForward=False — so sorting strategy is entirely a data-modeling problem: use immutable attributes in the primary key and push changing sort attributes into a GSI, zero-pad numbers embedded in string sort keys so lexicographic UTF-8 comparison matches numeric order, use KSUIDs for IDs that must be both unique and chronologically sortable, and position parent items relative to their children to control which end of an item collection a Query lands on.

27
DynamoDB

DynamoDB Filtering Strategies: Sparse Indexes and Composite Sort Keys

DynamoDB filtering is cheapest when it happens via the key condition, not after the read — composite sort keys concatenate a low-cardinality attribute (like an enum status) with a high-cardinality one (like a date) into a single sort key so one Query filters on both, sparse indexes exclude non-matching items at write time so the index itself is the filter, and FilterExpression is a last resort since it is applied after items are read, meaning you pay for all of the items that get filtered out; as of November 2025 AWS added native multi-attribute composite keys to GSIs, which the book's manual-concatenation technique still works identically alongside but no longer strictly requires.

28
DynamoDB

From Model to Implementation: DeBrie's Practical Rules for Building the Table

Once an access-pattern-first entity-relationship model is done, DeBrie gives six concrete rules for turning it into working code: keep indexing attributes (PK/SK) separate from application attributes, implement the data model only at the boundary of the application, never reuse an attribute across multiple indexes, tag every item with a Type attribute, write small CLI scripts to debug access patterns, and only for the largest tables, shorten attribute names to save storage.

60
Cassandra

Cassandra Data Modeling: Query-First Design, Chebotko Diagrams, and Partition Sizing

Cassandra data modeling runs conceptual model to application queries to logical model to physical model to a sizing pass, producing one denormalized table per query rather than one normalized table per entity — worked end to end on the book's hotel/reservation example, from Q1-Q9 through partition-size and disk-size arithmetic to the final CQL schema.

69
DynamoDB

Single-Table Design in DynamoDB: Why It Exists and When Not To Use It

Single-table design packs every entity type into one DynamoDB table so related items share a partition key and can be pre-joined into an item collection readable in a single Query — the only substitute DynamoDB offers for joins — but the book is equally explicit about its three costs and the two situations (fast-evolving greenfield apps, and GraphQL backends) where those costs win.

71
DynamoDB

DynamoDB Data Modeling: An Access-Patterns-First Approach

DynamoDB data modeling runs in the opposite direction from relational design — enumerate every access pattern before designing a key, since there are no joins to fall back on — and the book's five-step process (understand the app, ERD, access patterns, primary key, then secondary indexes) is now essentially AWS's own official guidance.

Key Design & Partitioning

Relationship Strategies

14
DynamoDB

DynamoDB Worked Case Study: Recreating GitHub with Adjacency Lists and GSI Overloading

Alex DeBrie's full GitHub data model — nine entity types, 24 access patterns, one table — shows the adjacency list and GSI overloading surviving contact with a real design: three separate GSIs each dedicated to a different relationship, the same Repo item overloading GSI2 with two different meanings depending on whether it's a fork, and Users-to-Organizations split so each many-to-many direction gets a different strategy instead of one pattern forced onto both.

67
DynamoDB

DynamoDB Strategies for Many-to-Many Relationships

Many-to-many is DynamoDB's hardest shape because you want to query both directions with no linking table to join through, and the book's four strategies — shallow duplication, adjacency list, materialized graph, and normalization with multiple requests — form a gradient ordered by how much mutable relationship data each can tolerate.

68
DynamoDB

DynamoDB One-to-Many Relationships: Five Modeling Strategies

With no joins available, a parent/child relationship in DynamoDB is modeled by picking one of five strategies per access pattern — embed the children in a complex attribute, duplicate the parent's data onto each child, pre-join them in one item collection behind a composite primary key, rebuild that collection in a secondary index, or smash a deep hierarchy into a composite sort key — each gated by a specific question the book makes you answer.

Advanced Mechanics

API & Access Patterns

Evolution & Migration

Consistency & Replication

12
Cassandra

Planning a Cassandra Cluster Deployment: Topology, Sizing, and Hardware

How to turn data volume, replication factor, and topology into an actual deployment plan: choosing SimpleStrategy vs NetworkTopologyStrategy for rack- and DC-aware replica placement, deriving node count from the book's storage formula and 1 TB/node guideline, and the hardware and network decisions (CPU/RAM, SSD vs HDD, JBOD vs RAID, avoiding load balancers) that back each node.

25
Cassandra

The Cassandra Elevator Pitch: Distributed, Decentralized, and Where It Came From

Cassandra's fifty-word elevator pitch unpacked as a high-level orienting map before any single mechanism: distributed and decentralized peer-to-peer architecture with no master, elastic scalability, high availability, tuneable consistency previewed against the CAP theorem, the row-oriented (not column-oriented) wide column data model, the Facebook-Dynamo-Bigtable origin story, and the book's own checklist for whether Cassandra fits a project at all.

26
Cassandra

Beyond Relational Databases: The CAP Theorem and Cassandra's Trade-offs

Why relational databases hit a wall at web scale, what Brewer's CAP theorem actually forces you to give up during a network partition, and why Cassandra's shared-nothing, AP-by-default architecture with tunable per-query consistency is a deliberate answer to that trade-off rather than a limitation.

38
Cassandra

Cassandra Storage Engine Internals: Memtables, SSTables, Compaction, and Bloom Filters

The on-disk machinery underneath Cassandra's write path: how a memtable accumulates writes in memory and flushes to an immutable SSTable, why SSTables must then be merged through compaction (SizeTiered/Leveled/TimeWindow, each a different workload trade-off), how Bloom filters let a read skip an SSTable without touching disk, and how tombstones and gc_grace_seconds interact with compaction to age out deletes — plus a book-vs-today note on Cassandra 5.0's opt-in Unified Compaction Strategy.

44
Cassandra

Cassandra Distributed Architecture: Gossip, Snitches, Tokens, and Virtual Nodes

How a Cassandra cluster agrees on membership and data placement without a coordinator: the gossip protocol and Phi Accrual Failure Detector for cluster state, snitches for topology-aware routing, the token ring and consistent hashing for deterministic partition ownership, and virtual nodes for balanced rebalancing.

57
Cassandra

Cassandra Read Path, Last-Write-Wins, and Read Repair

On a read, the coordinator asks the fastest replica for the row and every other replica for only a digest of it, resolves any disagreement by picking the cell with the latest timestamp (last write wins, with a lexicographic tiebreak), and then transparently read-repairs the replicas that answered with obsolete data as part of that same request — a mechanism that is opportunistic by design, is now configured by the Cassandra 4.0 read_repair table option rather than the book's removed read_repair_chance, and never replaces scheduled anti-entropy repair.

58
Cassandra

Cassandra Write Path and Lightweight Transactions

A Cassandra write is fast because the coordinator only waits for the commit-log-then-memtable step on each replica before acknowledging — the SSTable flush happens after the client is already told success — and lightweight transactions trade that speed for linearizability by running a full four-round-trip Paxos negotiation (prepare/promise, read/results, propose/accept, commit/ack) scoped to a single partition.

59
Cassandra

Cassandra Consistency Levels: Tunable Consistency, Quorums, and Coordinator Nodes

Cassandra separates the replication factor, set once per keyspace by SimpleStrategy or the production-recommended NetworkTopologyStrategy, from the consistency level chosen per query by the client, so a coordinator node forwards each read or write to the replicas that own the partition and returns as soon as ONE, QUORUM (floor(RF/2 + 1)), or ALL of them answer — with R + W > RF the formula for strong consistency, and hinted handoff plus repair covering the replicas that did not answer.

Indexing & Extending Designs

35
Cassandra

Vector Search and the VECTOR Type: Native Embeddings in Cassandra 5.0

Explains Cassandra 5.0's native vector search: the VECTOR<type, dimension> CQL type that stores an embedding as a normal fixed-length column value, and the ORDER BY ... ANN OF ... query that finds its approximate nearest neighbors. Shows that vector search is not a separate subsystem but Storage-Attached Indexing (SAI) applied to vectors — same CREATE INDEX ... USING 'sai' syntax, same per-SSTable attachment and query-planner behavior as SAI's text and numeric indexes, but backed by a JVector graph (a close cousin of HNSW, inspired by DiskANN) instead of a trie or k-d tree.

36
Cassandra

Secondary Indexes and Materialized Views: Cassandra's Pre-SAI Answers to Non-Partition-Key Queries

Cassandra's original built-in secondary index (2i) and materialized views, the two mechanisms for querying on a non-partition-key column before Storage-Attached Indexing existed: 2i's cluster-wide fan-out and hard cardinality/tombstone limits, SASI's partial per-SSTable fix, and materialized views' automatic-denormalization trade against write-path cost and the book's own admitted immaturity — the exact gap the sibling SAI concept closes.

49
Cassandra

Storage-Attached Indexes: Fixing Cassandra's Secondary Index and Materialized View Problem

Explains Storage-Attached Indexing (SAI), Cassandra 5.0's storage-engine-integrated secondary index: what it fixes about the older built-in secondary index (2i) and materialized views (cardinality cliffs, tombstone failures, per-column storage cost, denormalization consistency risk), how per-SSTable index attachment works mechanically, CQL syntax, and its newer text-analysis and vector-search (ANN) angles, plus where its limits still push you back toward query-first table design.

Data Types & Commands

17
Redis

Redis Memory Optimization and Internal Encodings

Redis in Action's memory-reduction chapter covers three techniques: short-structure encodings (ziplist/intset, whose Redis 7.0 rename to listpack is covered in the Core Data Types concept), sharding one logical HASH or SET across many keyed shards, and packing fixed-width records into Strings with GETRANGE/SETRANGE/GETBIT/SETBIT — the sharded-HASH pattern is still official Redis guidance today, while the sharded-SET-for-unique-counting use case has been substantially superseded by HyperLogLog's fixed ~12KB approximate count.

22
Redis

Redis Pub/Sub: Channels, Patterns, and Messaging Semantics

Redis Pub/Sub is a live broadcast built on SUBSCRIBE/PUBLISH/PSUBSCRIBE with no storage layer underneath: a message published to a channel with zero subscribers is lost forever, at-most-once, with no queue, no persistence, and no replay for a reconnecting client, and a subscribed connection is dedicated to receiving pushed messages until every channel and pattern is unsubscribed (RESP2) or RESP3 lifts that restriction; Redis 7.0's Sharded Pub/Sub (SSUBSCRIBE/SPUBLISH) scales the broadcast itself across a cluster by hashing shard channels to the same 16384 hash slots as keys, without changing any of those delivery guarantees.

34
Redis

Redis Transactions and Pipelines

MULTI/EXEC gives Redis a serialized, uninterrupted run of a queued command sequence, not a SQL-style rollback-on-error transaction — a command that fails during EXEC (e.g. LPOP against a string) does not abort the ones after it, so the app, not Redis, has to decide up front (via DISCARD) whether to run at all; WATCH layers optimistic-locking check-and-set on top, aborting EXEC if a watched key changed since the watch, while pipelines solve an entirely different problem — batching commands to cut network round trips, with no atomicity guarantee of their own — and the two are orthogonal: a pipeline can run without MULTI/EXEC, and MULTI/EXEC is itself always sent as a pipeline under the hood.

46
Redis

Redis Streams: Append-Only Logs and Consumer Groups

Redis Streams (5.0, 2018) are a persisted, append-only log with time-ordered entry IDs, read via XADD/XRANGE/XREAD — but the real payoff is consumer groups (XGROUP, XREADGROUP, XACK, XPENDING, XCLAIM/XAUTOCLAIM), which give multiple cooperating consumers per-message acknowledgment and crash recovery via a Pending Entries List, an at-least-once guarantee neither Pub/Sub's fire-and-forget fan-out nor a plain List-based queue provides natively.

55
Redis

Redis Advanced Data Types: Sets, Sorted Sets, Bitmaps, and HyperLogLog

Sets, Sorted Sets, Bitmaps, and HyperLogLog are four distinct data structures, not just more commands: Sets give O(1) unique membership with real set algebra (SINTER/SUNION/SDIFF); Sorted Sets keep a skip-list ordering by score that doubles as both a ranked leaderboard and a range index; Bitmaps repurpose a String as one bit per integer ID for compact boolean analytics; and HyperLogLog trades exactness for a fixed ~12 KB cardinality estimate regardless of scale.

56
Redis

Redis Core Data Types: Strings, Lists, and Hashes

Redis Strings, Lists, and Hashes are three distinct structures, not variations on key-value: Strings hold bytes/integers/floats with atomic SET/GET/INCR and a 512 MB cap; Lists are true linked lists giving O(1) push/pop at either end via LPUSH/RPUSH/LPOP/RPOP/LRANGE (O(N) for anything else) and power queues via BRPOP/RPOPLPUSH; Hashes map String fields to String values via HSET/HGET/HGETALL/HINCRBY, collapsing related fields (an Instagram case study cut 21 GB to roughly 5 GB moving from per-field String keys to Hashes) — and since Redis 7.0 the compact internal encoding both books call ziplist is renamed listpack.

Application Patterns

Coordination Primitives

Durability & Persistence

Security

23
Cassandra

Cassandra Security: Authentication, RBAC, and Encryption

Cassandra's opt-in, pluggable security model: PasswordAuthenticator and the default cassandra/cassandra superuser for authentication, CassandraAuthorizer and role-based GRANT/REVOKE for authorization, and TLS via server_encryption_options and client_encryption_options for node-to-node and client-to-node encryption in transit — plus why SSTable-level encryption at rest still isn't in open-source Cassandra even at 5.0.

37
MongoDB

MongoDB Security: SCRAM, x.509 Authentication, RBAC, and TLS

MongoDB's older, broader security layer beneath field-level encryption: SCRAM and x.509 certificate authentication (with a full CA-to-cluster tutorial from the book), role-based authorization from built-in roles like readWrite and dbOwner up to root, and TLS for encryption in transit — plus why Atlas enforces TLS by default while self-managed MongoDB still ships with it off.

47
Redis

Redis ACLs and Native TLS: From requirepass to Real Access Control

Redis's only pre-2020 security tools were a single shared requirepass password, rename-command obscurity, network-level firewalling, and stunnel-wrapped TLS since Redis had none natively — this concept covers why that was inadequate and walks through the real fix: Redis 6.0's ACL system (named users, per-command/category rules, per-key-pattern and per-channel access, selectors) and built-in TLS (tls-port, mutual-TLS-by-default, cluster/replication encryption) that replaced both gaps.

Modern Redis Capabilities

20
Redis

Redis Licensing History and the Valkey Fork

Redis shipped under permissive BSD 3-Clause from 2009 through 2023, then Redis Inc. relicensed it to dual RSALv2/SSPLv1 in March 2024 over cloud providers monetizing Redis without contributing back, prompting the Linux Foundation to launch the BSD-licensed, multi-vendor-governed Valkey fork (backed by AWS, Google Cloud, and Oracle) just eight days later; in May 2025 Redis Inc. added the OSI-approved AGPLv3 as a third licensing option for Redis 8, leaving today's Redis-vs-Valkey choice a genuine trade-off between Redis's first-to-ship features and Valkey's permissive license and multi-vendor governance.

32
Redis

Redis Functions: Replacing Ad Hoc Lua Scripting

Both source books teach ad hoc Lua scripting via EVAL/EVALSHA and a hand-rolled SCRIPT LOAD cache-miss wrapper because that was the only scripting Redis had in 2013-2015; Redis Functions (Redis 7.0, 2022) replaces it with named, versioned libraries loaded via FUNCTION LOAD and invoked with FCALL/FCALL_RO, which Redis itself persists to the AOF and replicates instead of leaving script durability to each client application.

45
Redis

Redis 8: JSON, Search, Vector Sets, and Time Series in Core

Redis 8 (May 2025) folded five formerly-separate, separately-licensed Redis Stack modules directly into core Redis for free: native JSON documents, full-text/vector search via the Redis Query Engine (FT.CREATE/FT.SEARCH), Time Series (TS.*), and five probabilistic structures beyond HyperLogLog (Bloom, Cuckoo, Count-min sketch, Top-K, t-digest) — plus a brand-new native Vector Sets data type (VADD/VSIM) for embedding similarity search, Redis's answer to the same AI/RAG need MongoDB addresses with Atlas Vector Search.

Scaling & Topology

Configuration & Tuning

108
PostgreSQL

Connection Pooling and Proxying: HAProxy and PgBouncer

Sizing a connection pool from RAM/CPU/disk first principles, routing writes/reads through HAProxy frontend-backend pairs with leastconn balancing, and multiplexing many clients onto few real PostgreSQL connections with PgBouncer's session/transaction/statement pool_mode trade-offs.

110
PostgreSQL

PostgreSQL Kernel Tuning for Availability: Dirty Pages, Swappiness, and THP

OS-level sysctl and /sys tuning that keeps PostgreSQL online under stress rather than just faster — byte-based vm.dirty_background_bytes/vm.dirty_bytes to avoid a huge emergency write flush, vm.swappiness=1 to keep backends out of swap, and disabling Transparent Huge Pages, whose khugepaged defragmentation can stall PostgreSQL for tens of seconds — a recommendation current PostgreSQL documentation now states explicitly.

118
PostgreSQL

Reducing Contention with Concurrent Index Creation

Why a plain CREATE INDEX locks a table against every write for the whole build, how CREATE INDEX CONCURRENTLY trades a slower, two-scan build for zero write blocking, its hard restrictions (no transaction block, one build per table, OLTP lock-wait pileups), and how today's official docs cover a real gap in the book's recipe: what to do when a concurrent build fails and leaves an INVALID index behind, plus REINDEX CONCURRENTLY — already available in the book's own target version, PostgreSQL 12, but never mentioned in the recipe.

122
PostgreSQL

Defusing Cache Poisoning: Warming PostgreSQL's Cache After a Restart

Why a cold OS/shared-buffer cache after a crash or restart can make a technically 'up' PostgreSQL server unusably slow, how to snapshot and reload the most active tables and indexes with pgFincore or pg_prewarm, and how pg_prewarm's autoprewarm background worker — already available well before PostgreSQL 12 — automates the entire snapshot/restore recipe without a hand-built active_snap table.

126
PostgreSQL

PostgreSQL pg_settings: Restart, Reload, and Session-Scope Contexts

How the pg_settings.context column tells you whether changing a setting needs a full postmaster restart, a SIGHUP reload, or a superuser/user-level SET, how IS DISTINCT FROM safely lists settings changed from their boot_val default, and how PostgreSQL 15's GRANT SET/ALTER SYSTEM ON PARAMETER now lets admins delegate specific superuser-context settings to non-superuser roles without a full superuser grant.

130
PostgreSQL

PostgreSQL Initial Configuration: Connections, Memory, WAL, and Planner Costs

How to set a defensible starting postgresql.conf for a highly available server — connection/memory sizing, WAL and checkpoint tuning, replication readiness, planner cost estimates, and logging — and which of the book's specific settings were renamed, removed, or became the default since 2020 (wal_level's hot_standby→replica, wal_keep_segments→wal_keep_size, checkpoint_completion_target's default now 0.9).

Monitoring & Troubleshooting

9
Cassandra

Performance Tuning: Caching, Compaction Throttling, and JVM/GC Settings

The tuning levers that sit on top of Cassandra's LSM-tree storage engine: key/row/chunk/counter caches and when each one actually helps, compaction throughput throttling and concurrency for when SSTable backlogs build up, and JVM heap/GC settings, with a book-vs-today check confirming Cassandra 5.0 now ships G1GC as the default (not the book's CMS) since CMS was removed entirely in JDK 14.

10
Cassandra

Cassandra Maintenance: Repair, Node Operations, and Backup

Covers the operator-run maintenance that keeps a Cassandra cluster healthy: anti-entropy repair via nodetool repair (full vs incremental, sequential vs parallel, primary-range and subrange repair, Merkle trees and overstreaming), the node lifecycle (adding nodes and data centers, diagnosing and replacing failed nodes, decommission/removenode/assassinate in order of preference), and backup/restore via snapshots and incremental backups (hard-linked SSTables, sstableloader, schema exclusion caveat).

11
Cassandra

Cassandra Monitoring: nodetool, Virtual Tables, JMX, and Metrics

How to actually look inside a running Cassandra node: the JMX/MBean layer (StorageServiceMBean, CompactionManagerMBean, GossiperMBean) that exposes internal state, the nodetool commands built on it (status, info, tpstats, compactionstats, tablestats), and the virtual tables feature (system_views, system_virtual_schema) that lets you query that same state with plain CQL — plus Dropwizard metrics, log configuration, and full query logging.

19
MongoDB

MongoDB Monitoring and Backup Strategies

What to actually watch on a running MongoDB deployment (mongostat/mongotop/serverStatus, memory and page faults, working set sizing, replication lag and oplog length, WiredTiger's ticketing system as lock-percentage's successor) and how to get data out safely (mongodump/mongorestore vs filesystem/volume snapshots, plus the sharded-cluster caveats), with book-vs-today notes on Atlas displacing Ops Manager as the default path and Cloud Manager's 2024 deprecation of older-version support.

106
PostgreSQL

Monitoring with Telegraf, InfluxDB, and Grafana

A push-based monitoring pipeline where Telegraf polls PostgreSQL (including arbitrary custom SQL via the extensible plugin) and pushes to InfluxDB for storage, with Grafana rendering dashboards — replication slot lag, XID wraparound age, and session-state counts as the metrics worth collecting.

107
PostgreSQL

Troubleshooting with pg_stat_activity, pg_stat_statements, and Locks

Reading live connection state via pg_stat_activity, finding high-frequency-not-just-slow queries via pg_stat_statements, and tracing blocker-to-blocked chains with pg_locks + pg_blocking_pids() — plus the predefined pg_monitor role that replaces the book's manual SECURITY DEFINER wrapper functions.

120
PostgreSQL

Terminating Rogue Connections: pg_cancel_backend, pg_terminate_backend, and tcpkill

The escalation path for evicting a misbehaving PostgreSQL client — from querying pg_stat_activity for long-running or idle-in-transaction sessions, through the gentler pg_cancel_backend() and the forceful pg_terminate_backend(), down to a network-level tcpkill when the client refuses to acknowledge termination — and how PostgreSQL 14's optional timeout argument on pg_terminate_backend() now lets the function itself wait for confirmation instead of requiring a manual re-check query.

124
PostgreSQL

Finding Your Busiest Tables: Activity and Bloat Stats in PostgreSQL

How to rank tables and indexes by size (pg_total_relation_size), by write/read activity (pg_stat_user_tables, pg_stat_user_indexes), and by bloat (the pgstattuple extension) — and how PostgreSQL 16's last_seq_scan/last_idx_scan columns solve the book's own complaint that activity counters have no associated timestamp.

HA & Replication

100
PostgreSQL

Data Distribution: Foreign Data Wrappers and DIY Sharding

Cross-server queries via postgres_fdw (CREATE SERVER, user mappings, foreign tables, IMPORT FOREIGN SCHEMA), building a hand-rolled sharding scheme with a bit-packed unique-ID generator, and why Citus is the more pragmatic path to real horizontal sharding today.

101
PostgreSQL

HA Automation with Patroni

Patroni's DCS-based architecture (etcd/ZooKeeper/Consul for consensus, HAProxy for routing, every node running the same reconciliation loop) for fully automated PostgreSQL failover, patronictl switchover for zero-downtime maintenance, and why Kubernetes operators (CloudNativePG, Zalando postgres-operator) have become a common deployment path today.

102
PostgreSQL

HA Automation with repmgr

How repmgr layers cluster metadata, one-command standby cloning, witness-based quorum, and repmgrd-driven automatic failover on top of native streaming replication — SSH/sudo trust requirements, promote_command/follow_command, and how it compares to Patroni for new deployments today.

103
PostgreSQL

Backup Management: Barman and pgBackRest

How Barman (centralized fleet backup via SSH/streaming, near-zero-RPO capability) and pgBackRest (self-contained, compressed, incremental/differential backups) go beyond pg_basebackup with catalogs, retention policies, and PITR — plus native cloud storage support and the PostgreSQL 15 removal of exclusive backup mode.

104
PostgreSQL

Native Logical Replication: Publications and Subscriptions

Row-level replication built into PostgreSQL since v10 — CREATE PUBLICATION/CREATE SUBSCRIPTION with no third-party tools, why DDL and sequences don't replicate, the replica-identity requirement for UPDATE/DELETE, and what PostgreSQL 15-19 added (row/column filters, conflict logging, pg_createsubscriber).

105
PostgreSQL

Streaming Replication, Hot Standby, and Replication Slots

How PostgreSQL builds log shipping, streaming replication, hot standby, replication slots, and synchronous replication all on top of the WAL — pg_basebackup/pg_receivewal, FIRST vs ANY synchronous_standby_names, hot_standby_feedback, and slot-based WAL retention safety valves.

111
PostgreSQL

Mitigating Hardware Failure: Delayed WAL Archiving vs. recovery_min_apply_delay

Why silent CPU/RAM corruption can poison a synchronous primary and standby nearly simultaneously, how archiving WAL to a tertiary server with a deliberate hour-long cron/mtime delay buys time to detect it before it spreads, why the book's own recovery_min_apply_delay example doesn't actually delay by an hour, and why data checksums — not the book's vague 'monitors' — are the real detection mechanism this recipe depends on.

114
PostgreSQL

Applying PostgreSQL Software Upgrades with Zero Downtime via Node Switching

How to patch PostgreSQL on both nodes of a primary/replica pair without ever taking the database fully offline, by upgrading the idle replica first, cutting over to it as the new primary, then rebuilding the old primary as a fresh replica — plus why pg_rewind, already available at the book's own PostgreSQL 12 target, replaces the recipe's wasteful full pg_basebackup re-copy of the demoted node.

116
PostgreSQL

Migrating a PostgreSQL Server with Streaming Replication

How to move a PostgreSQL database to new hardware with minimal downtime by building a streaming replica with pg_basebackup, waiting for it to catch up, then promoting it to primary — plus two gaps in the book's own PostgreSQL 12-era recipe: pg_stat_replication's sent_location/replay_location columns were already renamed to sent_lsn/replay_lsn back in PostgreSQL 10, and pg_basebackup's -R flag already automated the manual standby.signal/primary_conninfo setup the recipe walks through by hand.

131
PostgreSQL

PostgreSQL SLA Design: Defining Acceptable Downtime

How to translate 'who uses the database and what will they tolerate' into a concrete uptime target expressed in nines, and how the book's ad-hoc SLA checklist maps to today's formal SLI/SLO/SLA/error-budget vocabulary and published managed-Postgres SLA benchmarks (AWS RDS, Google Cloud SQL).

132
PostgreSQL

PostgreSQL Multi-Master Clusters: Latency, Mesh Overhead, and Zero-RTO Failover

How multi-master PostgreSQL trades the failover/quorum problem for a write-conflict-avoidance problem, why mesh topology overhead grows as C = N*(N-1), and how the 2020 book's generic 'proprietary software' framing maps to today's EDB Postgres Distributed and the newly open-source pgEdge/Spock.

133
PostgreSQL

PostgreSQL Split-Brain Prevention: Fencing, STONITH, and SMITH

How fencing guarantees a demoted or isolated PostgreSQL primary genuinely can't accept writes anymore — STONITH (remote power-off) and SMITH (self-power-off on isolation) — and how Patroni's built-in watchdog now automates the SMITH half via a Linux softdog/hardware watchdog device instead of a hand-rolled isolation check.

134
PostgreSQL

PostgreSQL Quorum Voting and Connection Indirection

How witness-node voting rules avoid tied elections during automated failover, and how connection indirection (DNS, VIP, connection multiplexer, or load balancer) keeps applications from needing reconfiguration when the primary changes — today typically HAProxy polling Patroni's own REST health-check API.

135
PostgreSQL

PostgreSQL Node Count and Geographic Placement

How to derive how many PostgreSQL nodes a highly available cluster needs (backup, replicas, witness) and where to place them across data centers, and how Patroni's DCS-based quorum has replaced the manually placed witness node.

136
PostgreSQL

RPO and RTO Planning for a Highly Available PostgreSQL Cluster

How Recovery Point Objective (data-loss tolerance) and Recovery Time Objective (downtime tolerance) drive PostgreSQL architecture decisions, and how synchronous replication's quorum commit turns an RPO target into an enforceable guarantee.

CQL Fundamentals

18
Cassandra

Migrating to Cassandra and Integrating with Kafka and Spark

Migrating to Cassandra is a re-modeling exercise, not a table-for-table port: the book's direct-translation patterns (entities to tables, join tables to mapped tables or collapsed UDTs, loose types to UDTs) still have to pass through the query-first methodology, plus the strangler pattern for adapting the application and dual-write/CDC for zero-downtime cutover. Integrating outward, Kafka Connect's DataStax sink connector streams events into Cassandra (with CDC-out remaining the harder, still-partially-solved direction), and the spark-cassandra-connector runs data-local analytics over Cassandra tables without a separate ETL pipeline — plus what changed since 2022 now that the Spark connector has moved to Apache governance and Debezium has largely closed the CDC-out gap the book left open.

24
Cassandra

Cassandra Application Development with the DataStax (Apache) Java Driver

Building a real Cassandra client with the Java driver: a single long-lived CqlSession built with the fluent builder, why PreparedStatement beats SimpleStatement for more than convenience (one-time preparation, token-aware routing, injection protection), the QueryBuilder and annotation-driven object mapper as higher-level alternatives, and async execution with CompletionStage — plus what changed since the book's 4.0-era coverage now that the driver is Apache-governed under org.apache.cassandra on the 4.19.x line.

61
Cassandra

The Cassandra Query Language: Keyspaces, Partitions, Columns, and CQL Types

Cassandra's data model built bottom-up from column to row to partition to table to keyspace to cluster, with the composite primary key (partition key plus clustering columns) that decides both node placement and on-disk order, per-column timestamps and TTL, and the full CQL type system from numeric and textual types through uuid/timeuuid, counters, the three collections, tuples, and frozen user-defined types.