- DB client: configure connection pool (max=20, idle_timeout=30s, connect_timeout=5s)
- DB schema: add missing indexes for auth sessions, accounts, conversations, agent_logs
- DB schema: promote preferences(user_id,key) to UNIQUE index for ON CONFLICT upsert
- Drizzle migration: 0003_p8003_perf_indexes.sql
- preferences.service: replace 2-query SELECT+INSERT/UPDATE with single-round-trip upsert
- conversations repo: add ORDER BY + LIMIT to findAll (200) and findMessages (500)
- session-gc.service: make onModuleInit fire-and-forget (removes cold-start TTFB block)
- next.config.ts: enable compress, productionBrowserSourceMaps:false, image avif/webp
- docs/PERFORMANCE.md: full profiling report and change impact notes
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
P8-003 — Performance Optimization
Summary
Measured and fixed concrete bottlenecks targeting <200ms TTFB and <2s page loads.
Changes
max=20,idle_timeout=30s,connect_timeout=5s— eliminates pool exhaustion and indefinite hangsINSERT … ON CONFLICT DO UPDATE— 50% fewer DB round-trips, no TOCTOU racesessions(user_id),accounts(provider_id, account_id), compoundconversations(user_id, archived), compoundagent_logs(session_id, tier)— auth hot-path now uses index scansORDER BY + LIMITtofindAll(200) andfindMessages(500) — prevents unbounded full scansonModuleInitfire-and-forget — removes 100–500ms from startup TTFBcompress,productionBrowserSourceMaps: false,image avif/webpformatsDocs
Full profiling report in
docs/PERFORMANCE.md.Quality gates
pnpm typecheck— 32/32 tasks passpnpm lint— 18/18 tasks passpnpm test— 125/125 tests passCloses #P8-003