How I discovered and fixed an N+1 query problem that was causing 50+ database queries per request.
API responses were taking 2+ seconds. Logging revealed 50-100 database queries per request. Each workout was triggering a separate query to fetch its exercises.
GraphQL resolver for 'exercises' field was fetching exercises one workout at a time. With 50 workouts in a plan, that's 50 separate queries.
Implemented DataLoader to batch and cache database queries. All exercises now fetched in a single query with WHERE workout_id IN (...). Response time dropped to 150ms.