Skip to content

Glossary#

Every PostgreSQL and pgdorm term used across The Elephant Dormitory, grouped by layer for quick lookup.

Schema & Modeling#

CTI (Class-Table Inheritance)
Polymorphic modeling where a shared base table (task) holds common columns and each subtype (cleaning_task, maintenance_task) lives in its own joined table sharing the same primary key. Enabled via joined=True. See Chapter 7.
Discriminator
A column identifying which subtype a polymorphic row belongs to. pgdorm forbids string discriminators: pg.discriminator(...) must reference a TypeTable primary key, and variants must be IntEnum members. See Chapter 7.
Exclusion constraint / WITHOUT OVERLAPS (GiST)
A native PostgreSQL temporal constraint (PRIMARY KEY (room_id, stay WITHOUT OVERLAPS) or UNIQUE (... WITHOUT OVERLAPS)) backed by a GiST index (scalar key columns use the btree_gist extension, which pgdorm installs for you) that forbids overlapping ranges for the same key. Violations raise ExclusionViolationError (23P01). See Chapter 6.
Partial index
An index with a WHERE predicate (for example WHERE out_of_service IS FALSE) that indexes only the active subset of rows, staying smaller and faster. See Chapter 4.
RLS (Row-Level Security)
Database-enforced per-row access policies (USING for reads, WITH CHECK for writes) evaluated inside PostgreSQL on every query. Paired with local_settings= in pgdorm for 1-RTT, PgBouncer-safe multi-tenancy. See Chapter 14.
STI (Single-Table Inheritance)
Polymorphic modeling where all variants (CardPayment, BankTransfer, VoucherPayment) live in one table guarded by a TypeTable discriminator and auto-generated disjoint CHECK constraints. See Chapter 7.
TypeDecorator
A reusable column codec subclassing pg.TypeDecorator[PyT, DbT] that transforms values automatically on bind (process_bind_param) and hydration (process_result_value), such as LowerEmail. See Chapter 4.
TypeTable
A small lookup table auto-generated and seeded from a Python IntEnum, using an INTEGER PK and a unique code column. Enforced by real foreign keys instead of raw strings. See Chapter 4.
UNSET (pg.UNSET)
Sentinel distinguishing "field omitted in PATCH" from None (deliberate SQL NULL). Prevents partial updates from wiping existing columns. See Chapter 2.
UUIDv7 (pg.uuidv7())
Time-ordered UUID built natively into PostgreSQL, combining unguessable public identifiers with B-tree index locality. See Chapter 4.
Virtual generated column
Default mode for GENERATED ALWAYS AS (...) VIRTUAL in PostgreSQL, computed on read with zero disk storage (Guest.full_name). Contrast with mode=pg.enums.GeneratedMode.STORED (Charge.amount). See Chapter 4.

Queries, Joins & Analytics#

CTE (Common Table Expression)
A named temporary result set inside a single SQL statement (WITH ... AS (...)). pgdorm supports both standard CTEs, writable CTEs (used automatically for 1-RTT CTI inserts), and typed WITH RECURSIVE CTEs with SEARCH and CYCLE. See Chapter 12.
Data-Modifying CTE (WriteCte)
A PostgreSQL writable WITH clause (WITH claimed AS (UPDATE ... RETURNING ...)) built via pg.write_cte(...) that executes a mutation and feeds its RETURNING rows directly into a downstream SELECT, INSERT, UPDATE, or DELETE in a single statement. See Field Note 6.
Keyset pagination
Cursor-based pagination using row-value comparisons such as (last_name, guest_id) > ($1, $2) so page 10,000 hits a B-tree index in O(log N) time instead of scanning and discarding rows like OFFSET. See Chapter 9.
Lateral Subquery (Select.join_lateral)
A correlated JOIN LATERAL (...) ON TRUE subquery that can reference columns from preceding FROM items, enabling O(W·K) index-backed Top-K per group without scanning the full detail table. See Field Note 6.
MERGE … RETURNING
PostgreSQL statement that atomically updates matching target rows and inserts non-matching rows from a source table (such as a pg_temp staging table), returning merge_action() (INSERT/UPDATE) plus OLD and NEW values in one statement. See Chapter 13.
Prepared-statement shape stability (= ANY($1) / UNNEST)
Keeping one canonical SQL text regardless of list or batch length so PostgreSQL parses, plans, and caches one prepared statement and produces stable log and pg_stat_statements entries (including for bulk inserts, which IN-list squashing does not cover). See Chapter 3.
RETURNING OLD/NEW
Native PostgreSQL clause allowing UPDATE, DELETE, and MERGE to return both the previous (pg.old(...)) and updated (pg.new(...)) values of a row in a single round trip. See Chapter 2.
SKIP LOCKED
Row-locking modifier (FOR UPDATE SKIP LOCKED) that skips rows currently locked by another transaction instead of blocking, turning an ordinary PostgreSQL table into a concurrent work queue. See Chapter 8.
split_load()
pgdorm's eager-loading helper that loads parent rows in RTT 1 and pipelines all child relation queries (= ANY($1)) in RTT 2 under a single REPEATABLE READ snapshot — zero N+1 and zero Cartesian bloat. See Chapter 5.

Wire Protocol, Hydration & Pooling#

Arrow C Stream (__arrow_c_stream__)
A standard zero-copy C interface for streaming columnar Apache Arrow RecordBatches between Python libraries (pgdorm, Polars, DuckDB, PyArrow) without converting rows into Python objects or CSVs. See Chapter 16 and Chapter 17.
Direct Slot Hydration
Decoding PostgreSQL v3 binary wire cells straight into CPython tp_alloc + Py_tp_descr_set slot descriptors in a single pass without intermediate Rust Value trees, Python attribute dictionaries, or tuple call frames. See Field Note 5.
ETL / ELT / EtLT
Three patterns for moving data into a database or warehouse: ETL transforms data before loading (e.g., Polars → copy_from_arrow()), ELT loads raw data first and transforms inside PostgreSQL SQL (pipe.stage() + pg.merge()), and EtLT runs lightweight pre-load cleanup/typing (on_error="ignore" or Polars) before heavy SQL transforms. See Chapter 13 and Chapter 17.
PgBouncer (pool_mode=pg.enums.PoolMode.TRANSACTION)
A lightweight PostgreSQL connection pooler that assigns a server connection only for the duration of one transaction. Requires transaction-scoped settings (set_config(..., true)) and ON COMMIT DROP temp tables. See Chapter 13 and Chapter 14.
Pipeline (pool.pipeline() / tx.pipeline())
Sending multiple PostgreSQL extended-query messages (Parse/Bind/Execute) in one TCP write before a single Sync, completing all statements — including lazy BEGIN and COMMIT — in 1 RTT. See Chapter 10.
Reverse ETL
Moving curated analytical outputs (audit records, scores, customer segments, pricing tiers) from an analytical engine or lakehouse (DuckDB, Parquet, Polars) back into an operational PostgreSQL OLTP database — done zero-CSV in pgdorm via copy_from_arrow() (append) or pg_temp staging + pg.merge() (upsert). See Chapter 17.
RTT (Round Trip Time)
One full network exchange between your application and PostgreSQL. Counted explicitly in tests with pool.trace() (assert tr.rtts == 1). See Prologue and Chapter 10.
Server JSON Aggregation (pool.json(..., mode="server"))
Wrapping a compiled query in PostgreSQL row_to_json / json_agg (OID 114 binary json) so the database emits a ready-to-forward UTF-8 JSON payload in 1 RTT, minimizing client CPU instructions. See Field Note 5 and Chapter 18.

Migrations & Assimilation#

Online migration
Schema evolution broken into lock-friendly steps (CREATE INDEX CONCURRENTLY, ADD CONSTRAINT ... NOT VALID, VALIDATE CONSTRAINT) guarded by lock_timeout / statement_timeout so production reads and writes stay unblocked. Provided by pgdorm.migrate. See Chapter 19.