Menu

Post image 1
Post image 2
1 / 2
0

I built a NuGet middleware to catch N+1 problems and slow queries in ASP.NET Core

DEV Community·Bruno Ferreira·20 days ago
#wHjEybHK
Reading 0:00
15s threshold

Every .NET developer has been there: the app feels slow, you open the logs, and you find the same query firing 50 times per request. N+1 problems are easy to introduce and annoying to find. So I built DbEye — a lightweight ASP.NET Core middleware that detects N+1 query problems and slow queries automatically, per HTTP request, right in your development terminal. What it does DbEye hooks into EF Core via an interceptor and tracks every query fired during a request. When something looks wrong, it logs a warning directly in your console: N+1 detected: warn: DbEye[0] ⚠️ N+1 detected at GET /api/posts Query repeated 100x - SELECT * FROM "Comments" WHERE "PostId" = ... Enter fullscreen mode Exit fullscreen mode Slow query detected: warn: DbEye[0] ⚠️ Slow query detected at GET /api/comments Duration: 732ms - SELECT * FROM "Comments" Enter fullscreen mode Exit fullscreen mode No external dashboard. No extra services to run. Just clear warnings where you already look. Setup in 3 lines builder . Services .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More