Back to Blog
January 8, 2026 1 min read

Debugging N+1 Queries in Player Stats

Bug Fix
Depth: ●●○○○
Share:

How I identified and fixed database performance issues that were causing 4+ second load times.

The player stats page was loading in 4.2 seconds. After investigation, I found the culprit: an N+1 query pattern that was making hundreds of individual database calls.

Finding the Problem

Using Prisma's query logging, I discovered that loading 50 players was triggering 51 queries - one for the list, then one for each player's stats. Classic N+1.

Bar Chart