I have a database table (running on SQL Server 2012 Express) that contains ~ 60,000 rows.
I am using the following code to purge old rows:
//Deleting CPU measurements older than (oldestAllowedTime)
var allCpuMeasurementsQuery = from curr in msdc.CpuMeasurements where
curr.Timestamp < oldestAllowedTime select curr;
foreach (var cpuMeasurement in allCpuMeasurementsQuery)
{
msdc.CpuMeasurements.Remove(cpuMeasurement);
}
When the number of deleted rows is large (~90% or more of the records in the tables are being deleted) the operation takes exceptionally long. It takes about 30 minutes to finish this operation on an relatively strong machine (Intel I5 desktop).
does this seem like a normal behavior?
any ideas about what I can do to reduce the operation's time?
Thanks,