SQLAlchemy 2.0 Textbook Ch. 12 — Production Patterns
Production SQLAlchemy: pool sizing with PgBouncer, read replica routing, OTEL instrumentation, multi-tenancy with RLS, and graceful failure modes.
Production SQLAlchemy: pool sizing with PgBouncer, read replica routing, OTEL instrumentation, multi-tenancy with RLS, and graceful failure modes.
Cheatsheet: per-tenant engine cache, connection routing, multi-DB Alembic, onboarding.
Cheatsheet: SoftDeleteMixin, auto-timestamps via events, audit log table, with_loader_criteria for transparent filtering.
Cheatsheet: Vector column, cosine_distance / l2 / inner_product, HNSW index, hybrid filter + ANN.
Cheatsheet: shared DB + tenant_id, schema-per-tenant, DB-per-tenant, query filters, context propagation.
Cheatsheet: writer/reader engines, target_session_attrs, read-after-write, replica lag awareness.
Cheatsheet: N+1, IntegrityError, DetachedInstanceError, MissingGreenlet, lazy-load in async, pool exhaustion.
Cheatsheet: Mapped types, mapped_column with types, type_annotation_map, Annotated types, generic mapping.
Cheatsheet: single-table inheritance, joined-table inheritance, concrete inheritance, polymorphic loading, with_polymorphic.
Cheatsheet: when to use hybrid_property vs column_property vs Computed, with FastAPI integration.