We recently deleted a large number of records from out database. After the delete this statement generated from the Entity Framework is timing out. We're setting SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED for these statements as well.
Entity framework code
_emailSendResultsRepository.GetTable().Count(e => e.EmailId == email.Id && e.SendDate >= startDate);
Generates this sql
SELECT
[GroupBy1].[A1] AS [C1]
FROM ( SELECT
COUNT(1) AS [A1]
FROM [dbo].[EmailSendResults] AS [Extent1]
WHERE ([Extent1].[EmailId] = @p__linq__0) AND ( CAST( [Extent1].[SendDate] AS datetime2) >= @p__linq__1)
) AS [GroupBy1]
- If I run the same statement via Sql management studio it returns instantly.
- Counts to the same table without the date return quickly
- All other data calls seems to be working fine.
Any ideas what would be causing the timeout?