Production hit MySQL error 1461 (max_prepared_stmt_count = 16382), causing
fast 500s on /v1/prompt/batch and other endpoints. sqlx caches up to 100
prepared statements per connection by default, so 7 replicas x 50
connections could hold ~35k statements, more than twice the server cap.
- statement_cache_capacity defaults to 25 (MYSQL_STATEMENT_CACHE_CAPACITY),
bringing the ceiling to ~8.75k at current scale.
- max_lifetime defaults to 10 minutes (MYSQL_MAX_LIFETIME_SECONDS), down from
sqlx's 30, so statements orphaned by cancelled queries are released sooner.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>