Performance Improvements
Database Optimizations
- Added indexes on
play_historytable (account_id,viewed_at, composite index) - Added lookup index on
cached_statstable - Replaced
.lengthwith SQLCOUNT()aggregate for play history counts - Fixed N+1 query issue in top viewers calculation
- Batched metadata writes inside transactions to reduce overhead
SSE Stream Efficiency
- Sync status stream: Adaptive polling (500ms active → 2000ms idle)
- Log stream: Exponential backoff polling (1s → 5s)
- Reduced SSE idle network traffic by approximately 75%
Performance Results
| Metric | Before | After | Improvement |
|---|---|---|---|
| Stats page TTFB | 791ms | 58ms | 92.7% faster |
| Stats page LCP | 913ms | 273ms | 70.1% faster |
Full Changelog: 0.1.0...0.1.1