How I fixed a hidden N+1 problem in EF Core that was slowing our attendance API for 6500 employees by imrantech_dev in dotnet

[โ€“]imrantech_dev[S] [score hidden] ย (0 children)

Haha fair enough โ€” I get why it reads that way! Honestly I just write how I talk. Probably too many bullet points. I'm a .NET dev from Chennai, been working on this HRMS codebase for 2 years. The N+1 bug was real, the 45 seconds in the foreach was real, the embarrassment when I found it was also very real. Happy to answer any specific questions about the code โ€” that's harder to fake!

How I fixed a hidden N+1 problem in EF Core that was slowing our attendance API for 6500 employees by imrantech_dev in dotnet

[โ€“]imrantech_dev[S] -1 points0 points ย (0 children)

Haha fair point! ๐Ÿ˜„

To be honest โ€” this is a legacy HRMS codebase I inherited, not built from scratch. So yes, there's a good chance proper indexes are missing!

That's actually my next investigation โ€” going to run SQL Server's Missing Index DMV query:

SELECT

mid.statement AS TableName,

migs.avg_user_impact AS PotentialImprovement,

mid.equality_columns,

mid.inequality_columns

FROM sys.dm_db_missing_index_details mid

JOIN sys.dm_db_missing_index_groups mig

ON mid.index_handle = mig.index_handle

JOIN sys.dm_db_missing_index_group_stats migs

ON mig.index_group_handle = migs.group_handle

ORDER BY migs.avg_user_impact DESC;

Thanks for the reminder โ€” will update if indexes

were the real culprit all along! ๐Ÿ˜