[英]SQL Server EF Core Row Deletion Performance
I've got a simple 3-column table to track pending calculations. 我有一个简单的3列表来跟踪未完成的计算。 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.
该表的主键是客户端FK和日期的组合。
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.
具体来说,当它有大约1000行并且计算被短路时,从队列中仅删除一行并调用SaveChanges平均需要三秒钟。
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.
但是我不确定,我还是MS SQL和EF Core的新手。 Can anyone point me in the right direction to profiling this to identify the bottleneck?
谁能指出我正确的方向来进行分析以找出瓶颈?
I would start by profiling the app through Visual Studio ( Debug > Performance Profiler
) to see where the problem actually is: 我将首先通过Visual Studio(
Debug > Performance Profiler
)对应用程序进行性能分析,以查看问题的实际出处:
I hope these ideas help you to fix the problem. 我希望这些想法可以帮助您解决问题。 Good luck ;-)
祝好运 ;-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.