SQLAlchemy Cheatsheet 08 — Performance, N+1, Bulk Ops, Streaming
Cheatsheet: detect N+1, bulk insert/update, yield_per, load_only, defer, EXPLAIN, slow query logging.
Cheatsheet: detect N+1, bulk insert/update, yield_per, load_only, defer, EXPLAIN, slow query logging.
Production Alembic: deploy strategies, recovery from broken migrations, stamp, manual fixes, and the operational checklist.
JSON Schema from Pydantic: model_json_schema, OpenAPI integration, custom schemas, examples.
Async patterns in SQLAlchemy 2.0: AsyncSession, expire_on_commit, async streaming, lazy loading caveats, AsyncSession scopes.
Cheatsheet: when to use each profiler, common commands, reading output.
Cheatsheet: Dockerfile, K8s Deployment, migration Job, secrets, probes, graceful shutdown.
Cheatsheet: K8s Job vs app-startup, advisory-lock single runner, forward-only, recovery via stamp.
Cheatsheet: BaseSettings, env_file, env_prefix, nested, secrets_dir, CLI integration.
Cheatsheet: Alembic setup with SQLAlchemy 2.0, env.py for sync/async, naming conventions, common ops.
Pydantic-settings: typed env config, .env, secrets directory, sources, CLI integration.