Analyze the code for performance optimization opportunities. Focus on: 1. **Algorithm Efficiency** - Time complexity analysis - Space complexity analysis - Suggest more efficient algorithms 2. **Database Optimization** - Query optimization - Index recommendations - N+1 query problems - Caching opportunities 3. **Memory Management** - Memory leaks - Unnecessary object creation - Resource cleanup 4. **Code Structure** - Redundant computations - Unnecessary loops or iterations - Lazy loading opportunities 5. **Network/IO Operations** - Batch operations - Connection pooling - Async/await optimization 6. **Caching Strategy** - What should be cached - Cache invalidation strategy - Memory vs performance tradeoffs Provide specific refactoring suggestions with before/after code examples showing the performance improvements.