Reputation: 1368
I've got a simple 3-column table to track pending calculations. The first column is an integer Foreign Key linking to a clients table. The second is a date and the third is a priority flag. The primary key for the table is a composite of the client FK and the date.
This table is used for a calculation queue, so it sees a lot of churn. What I noticed, however, is that working with this table itself is sometimes slower than the actual calculations that it's a queue for. Specifically, when it has about 1000 rows, and the calculation is short-circuited, removing just one row from the queue and calling SaveChanges takes on average three seconds.
With this table constantly being added to and removed from, those three seconds add up quick. And it has to be done serially to ensure the queue is tackled in the correct order. It just seems like an inordinately long amount of time to remove a single row on a three-column table.
I'm guessing the composite key is to blame...? But I'm not sure, and I'm new to MS SQL and EF Core. Can anyone point me in the right direction to profiling this to identify the bottleneck?
Upvotes: 0
Views: 44
Reputation: 9437
I would start by profiling the app through Visual Studio (Debug > Performance Profiler
) to see where the problem actually is:
I hope these ideas help you to fix the problem. Good luck ;-)
Upvotes: 1