← You Don't Need MongoDB
Glossary
The terms a careful reader will want to keep at the elbow. Document-oriented PostgreSQL terminology, MongoDB terms that map to it, and the operational vocabulary that lives in both worlds.
- Advisory lock
- A cooperative application-level lock in PostgreSQL, identified by a 64-bit integer, automatically released when the session ends.
pg_try_advisory_lockreturns immediately without blocking — useful for guarding concurrent operations across multiple application instances without table-level locks. (Chapter 5 of You Don't Need Redis; referenced in Book 3 for matview refresh coordination.) - Aggregation pipeline
- MongoDB's stage-oriented grammar for expressing intent over documents. A composable sequence of
$match,$group,$sort,$project,$unwind,$lookup, and friends. Gold Lapel'sdoc_aggregateaccepts the same pipeline shape and lowers it into a single SQL statement, one CTE per stage. (Chapters 8, 12; Appendix E.) - Atlas
- MongoDB's managed database service. The most approachable on-ramp to a managed database in the market, with hosting, backups, monitoring, and scaling from a single dashboard. Atlas is excellent software; the argument of this book is operational simplicity, not product quality. (Chapters 1, 15.)
- BSON
- Binary JSON, MongoDB's storage format. Includes types JSON cannot represent (ObjectId, date, 64-bit integer, decimal, binary). Extended JSON is the text encoding used by
mongoexportto round-trip BSON through JSON. (Chapter 4, 17.) - Capped collection
- A MongoDB collection bounded by document count or byte size. Older documents are removed automatically when new ones arrive. Gold Lapel's
doc_create_cappedimplements the same semantics with anAFTER INSERTtrigger that counts rows and deletes the oldest when the cap is exceeded. (Chapter 13.) - Change stream
- MongoDB's event stream of
{operationType, documentKey, fullDocument, updateDescription}records, backed by the replication oplog. Gold Lapel'sdoc_watchdelivers the same event shape via a row trigger andLISTEN/NOTIFY. (Chapter 13.) - Citus
- A PostgreSQL extension (now part of Azure Cosmos DB for PostgreSQL) providing distributed table sharding, distributed query execution, and reference tables. Gold Lapel auto-detects Citus at startup; indexes propagate to all shards. The mature path for sharding PostgreSQL up to tens of nodes. (Chapter 18.)
- Collection
- MongoDB's container for documents. Maps one-to-one to a PostgreSQL table with a
data jsonbcolumn, auto-created by the firstdoc_insertcall. - Containment operator (
@>) - PostgreSQL's JSONB operator that asks whether the left operand contains the right.
data @> '{"status": "active"}'is the workhorse of indexed document filtering, served by both GIN operator classes. (Chapter 4.) COPY- PostgreSQL's bulk-load command. The fastest path into the database, accepting raw JSON for
jsonbcolumns directly. Used during migrations to load tens of thousands of documents per second per worker. (Chapter 17.) - CTE (Common Table Expression)
WITH name AS (...) SELECT .... Named subqueries inlined into a single statement. PostgreSQL 12 made CTEs inlineable by default unless markedMATERIALIZED; earlier versions treated them as optimization fences. Gold Lapel'sdoc_aggregatelowers each pipeline stage to a CTE. (Chapter 12.)- Document
- A JSON-shaped record. In MongoDB, stored as BSON. In PostgreSQL, stored as JSONB in a
datacolumn. The whole document lives in one row. - Dot notation
- Filter syntax expressing nested field access:
{"addr.city": "NY"}expands to{"addr": {"city": "NY"}}before SQL generation. Sibling merge preserves the indexed fast path. (Chapter 10; Appendix D.) - Expression index
- A B-tree (or other) index on the result of a function or expression, not a column.
CREATE INDEX users_age_idx ON users (((data->>'age')::numeric)). The cast chain in the index must match the generated SQL exactly. Required for fast comparison queries on JSONB fields. (Chapter 6.) - Extended JSON
- MongoDB's text encoding that wraps BSON-only types as tagged objects:
$oid,$date,$numberLong,$numberDecimal,$binary. Relaxed mode (the default) only wraps what JSON cannot represent. The five wrappers your migration loader will encounter. (Chapter 17; Appendix A.) - Generated column
- A column whose value is computed from other columns by an expression.
email TEXT GENERATED ALWAYS AS (data->>'email') STOREDextracts a JSONB field into a typed, indexable column without asking the application to change how it writes. PostgreSQL 12+ forSTORED; PostgreSQL 18 addedVIRTUAL. (Chapters 16, 17.) - GIN index
- Generalized Inverted Index. The standard PostgreSQL index type for JSONB containment queries, full-text search (
tsvector), array operations, and trigram similarity. Two operator classes for JSONB:jsonb_path_ops(smaller, faster,@>only) andjsonb_ops(larger, broader, supports?,?|,?&key-existence operators). (Chapters 4, 6.) gen_random_uuid()- PostgreSQL's built-in UUID v4 generator. Native since PostgreSQL 13 — no extension required. Used as the default for
_idin document collections. (Chapter 4.) - GiST index
- Generalized Search Tree. Supports geometric types, range types, certain full-text scenarios, and PostGIS spatial queries. The right index for
geographycolumns derived from JSONB lat/lon fields. - Gold Lapel mesh
- A topology in which Gold Lapel proxy instances discover each other and propagate cache invalidation across instances in real time. The fifth rung on Chapter 18's scaling ladder. (Chapter 18.)
jsonb- PostgreSQL's binary JSON column type. Parsed once on write, stored in a decomposed binary structure with sorted keys and an offset table for O(log n) random field access, never re-parsed on read. Available since PostgreSQL 9.4 (December 2014). The foundation of every chapter in this book. (Chapter 4.)
json(the other one)- PostgreSQL's text-based JSON column type. Validates JSON syntax but stores the text verbatim. Not indexable in the way
jsonbis. For queryable document data, the answer is alwaysjsonb. (Chapter 17.) jsonb_agg- PostgreSQL aggregate function returning a JSONB array of input values. The SQL target for MongoDB's
$pushaccumulator and the engine behind$lookup's array-of-matched-documents output. (Chapter 12.) jsonb_array_elements- PostgreSQL set-returning function that unnests a JSONB array into one row per element. Available since 9.3. The mechanism behind
$unwindand$elemMatch. The text-returning variantjsonb_array_elements_textis used for scalar arrays. (Chapters 5, 10, 12.) jsonb_build_object- PostgreSQL function constructing a JSONB object from key/value argument pairs. The SQL target for
$project's document reshaping. Available since 9.5. (Chapter 12.) jsonb_ops- The default GIN operator class for JSONB. Indexes every
{path, value}pair and supports@>,?,?|,?&. Larger thanjsonb_path_ops; choose it when you need key-existence queries. (Chapter 6.) jsonb_path_ops- The compact GIN operator class for JSONB. Indexes hashed leaf paths and supports
@>,@?,@@only. Smaller and faster for containment-only workloads. The default for Gold Lapel auto-created indexes. (Chapter 6.) jsonb_set- PostgreSQL function writing a value at a path within a JSONB document. The SQL target for MongoDB's
$set,$inc,$push, and other mutating operators. (Chapter 11.) jsonpath- SQL/JSON path language for complex queries against JSONB. Available since PostgreSQL 12.
data @? '$.tags[*] ? (@ == "python")'checks whether any element of thetagsarray equals"python". (Chapter 5.) LISTEN/NOTIFY- PostgreSQL's built-in publish/subscribe mechanism. Asynchronous, transactional (held until COMMIT), payloads up to 8000 bytes. The transport for change streams in
doc_watch. Reliable production-grade event fanout since 9.0 (2010). (Chapters 1, 13.) - Materialized view
- A database object storing the result of a query as a physical heap table with its own storage and indexes.
REFRESH MATERIALIZED VIEW CONCURRENTLYupdates it without blocking reads (requires a unique index). Gold Lapel uses matviews to cache aggregation pipeline results. (Chapter 12.) - Mesh
- See Gold Lapel mesh.
mongodump- MongoDB's binary backup tool. BSON output, faster and more compact than
mongoexport's JSON. The right tool for very large collections during migration. (Chapter 17.) mongoexport- MongoDB's JSON export tool. Emits Extended JSON v2, by default in relaxed mode.
--jsonArrayproduces a single JSON array; without it, NDJSON (one document per line). The friendly starting point for small-to-medium collections during migration. (Chapter 17.) - MVCC
- Multi-Version Concurrency Control. PostgreSQL's mechanism for letting readers and writers proceed without blocking each other. Every UPDATE produces a new tuple version; old versions are reclaimed by VACUUM. The substrate beneath every transaction. PostgreSQL has used MVCC as the default since 6.5 (June 1999). (Chapter 14.)
- Oplog
- MongoDB's replication log. The append-only journal of every write, used by replicas to stay in sync and by change streams to surface events. PostgreSQL's WAL is the structural equivalent.
- Operator class
- In PostgreSQL, a set of operators an index supports. For JSONB GIN, the choice is
jsonb_ops(broader) orjsonb_path_ops(narrower, smaller, faster for@>). Choosing the wrong opclass costs index size and scan speed permanently — until you rebuild. (Chapter 6.) ON CONFLICT DO UPDATE- PostgreSQL's atomic upsert syntax.
INSERT ... ON CONFLICT (target) DO UPDATE SET ...performs an insert if the row is absent and an update if a unique-constraint conflict occurs. Available since 9.5. The mechanism behind document upsert. No race condition. (Chapter 11.) - Partial index
- An index covering only a subset of a table's rows, defined by a
WHEREclause. Smaller and faster for queries that only ever target the indexed subset. (Chapter 6.) pg_cron- PostgreSQL extension providing cron-style job scheduling inside the database as a background worker. The native scheduler for matview refresh, TTL sweeps, and other periodic maintenance. Supported on every major managed PostgreSQL platform. (Chapter 13.)
pg_dump- PostgreSQL's logical backup tool. Captures schema, data, indexes, functions, and permissions in a single command. Portable across versions. The "one backup" the books keep returning to.
pg_jsonschema- PostgreSQL extension providing JSON Schema validation as a
CHECKconstraint on JSONB columns. Define a schema, enforce it at the database level, evolve it withALTER TABLE. (Chapter 7.) pg_notify- Function form of
NOTIFY, callable from PL/pgSQL trigger functions. Used inside change-stream triggers to publish event payloads to listening clients. (Chapter 13.) pg_trgm- PostgreSQL extension for trigram-based similarity matching. Enables fuzzy search, typo tolerance, autocomplete. Indexable with GIN and GiST. The right tool for
$regexsubstring patterns when prefix B-tree indexes are insufficient. (Chapter 10.) pgvector- PostgreSQL extension storing embeddings as a native type, with HNSW and IVFFlat indexes. Embeddings live in the same row as the document they describe — no separate vector database, no sync job. (Chapter 14.)
- Pipeline mode (libpq)
- A PostgreSQL client protocol feature shipped in version 14 that allows a client to issue multiple statements before reading any response, eliminating the per-query round-trip on small writes. On the Gold Lapel roadmap as part of write acceleration. (Chapter 15.)
- PostGIS
- PostgreSQL extension adding spatial types (
geometry,geography), spatial GiST indexes, and several hundred spatial functions. Among the most respected open-source geospatial software in existence; it happens to live inside your database. (Chapter 14.) - Replica set
- MongoDB's replication topology: a primary plus secondaries, with automatic failover. PostgreSQL's structural equivalent is streaming replication (primary + standbys), with synchronous or asynchronous commit modes.
SKIP LOCKED- PostgreSQL's
FOR UPDATE SKIP LOCKEDclause, available since 9.5. If another session holds the row's lock, this session moves on rather than blocking — the exact shape of a work-stealing queue. The mechanism behinddoc_find_one_and_updatefor queue workloads. (Chapter 11.) - Streaming replication
- PostgreSQL's primary-to-replica replication via WAL streaming. The structural equivalent of MongoDB's replica set replication via the oplog.
- Trigger
- A PL/pgSQL (or other PL) function attached to a table, fired on
INSERT,UPDATE, orDELETE. Row-level triggers have shipped since PostgreSQL 6.4 (1998). The native event mechanism that powers change streams, TTL sweeps, and capped collections in Gold Lapel. (Chapter 13.) - TTL index
- In MongoDB, an index instructing a background thread to delete documents older than a configured age. In PostgreSQL via Gold Lapel: an expression index on the TTL field plus a sweep trigger (or a scheduled
pg_cronDELETE). Same semantics, no separate background thread. (Chapter 13.) tsvector- PostgreSQL's full-text search data type. Sorted list of lexemes with positional information. Supports stemming, stop-word removal, boolean operators, phrase matching, relevance ranking via
ts_rank. Indexable with GIN. Available since PostgreSQL 8.3 (2008). The PostgreSQL inverted index. (Chapter 5; treated in full in You Don't Need Elasticsearch.) - UUID
- Universally Unique Identifier, 128 bits. Generated by
gen_random_uuid()in PostgreSQL. The canonical_idtype for Gold Lapel collections. Larger than MongoDB's 12-byte ObjectId but with a much lower collision probability and broader ecosystem support. - WAL (Write-Ahead Log)
- PostgreSQL's transaction durability mechanism. Every change is written to the WAL before being applied to the data files, ensuring crash recovery and driving streaming replication. The equivalent of MongoDB's oplog at the storage layer. (Chapters 4, 15.)
- WiredTiger
- MongoDB's default storage engine since 3.2. B-tree-based with a journal. Tuned for the append-heavy patterns document workloads tend to produce. The architectural reason for MongoDB's write-throughput edge over PostgreSQL with
synchronous_commit = on. (Chapter 15.)