Postgres SQLAlchemy Textbook Ch. 7 — Partitioning Strategies
Postgres declarative partitioning via SQLAlchemy: range/list/hash partitions, pg_partman automation, indexes per partition.
Postgres declarative partitioning via SQLAlchemy: range/list/hash partitions, pg_partman automation, indexes per partition.
Transactions and concurrency: isolation levels, savepoints, FOR UPDATE locking, optimistic locking, retry patterns, and the cross-DB differences.
Cheatsheet: NOTIFY from a transaction, listen via asyncpg, outbox + LISTEN wake-up pattern.
Cheatsheet: detect N+1, bulk insert/update, yield_per, load_only, defer, EXPLAIN, slow query logging.
Postgres RLS for multi-tenant SQLAlchemy: defining policies, setting tenant context per request, and integration with FastAPI.
Async patterns in SQLAlchemy 2.0: AsyncSession, expire_on_commit, async streaming, lazy loading caveats, AsyncSession scopes.
Cheatsheet: enable RLS, write policies, set tenant per request, application role without BYPASSRLS.
Cheatsheet: Alembic setup with SQLAlchemy 2.0, env.py for sync/async, naming conventions, common ops.
Postgres-specific bulk operations: ON CONFLICT, RETURNING, bulk insert via execute, asyncpg COPY for huge data.
Practical SQLAlchemy performance: avoiding N+1, bulk_insert_mappings, server-side cursors, EXPLAIN ANALYZE patterns.