Databases & ORM
SQLAlchemy sessions, connection pools and query patterns.
5 articles
MySQL server has gone away: four unrelated causes, one message
Errors 2006 and 2013 are a shrug, not a diagnosis. Idle timeouts, packet size, read timeouts and a crashed server all produce them, and each needs a completely different fix.
FATAL: sorry, too many clients already - and why raising max_connections is wrong
Every Postgres connection is a separate OS process, so raising max_connections trades a clear error for an OOM. Here is the connection maths and the PgBouncer fix.
The ORM N+1 Query Problem: Why It Ships to Production Undetected
A page that should issue 2 queries issues 201, and no tool catches it before production. Here is how N+1 hides, how to spot it, and the one-line fix per ORM.
QueuePool Limit Reached Under FastAPI Load: pool_size Is Not the Fix
The SQLAlchemy QueuePool timeout under FastAPI load is about how long connections are held, not how many exist. Why raising pool_size fails, and the async session scoping that works.
FastAPI yield Dependencies: How Cleanup Works and Where It Silently Breaks
FastAPI 0.106 moved yield-dependency teardown to run before the response, silently breaking background tasks and middleware commits. Here is the fix that survives upgrades.