I've inherited a C# / ASP.NET MVC / Entity Framework project with some slowness. There's not a lot of data in the DB but calls to .Include()
were causing slowdowns.
However, I found something very strange. I have a 2k row table with just numbers (5 columns). I have indexes on the columns I'm searching.
When doing:
_entities.MyTable.Where(x=> x.Id1 == 4 && x.Id2 == 5).First()
it takes 1800ms on my development machine.
However, when I do :
_entities.MyTable.Where("it.Id1 = 4 and it.Id2 = 5").First()
it takes like 10ms.
What's the deal? I don't understand why the LINQ expression would be so slow.