I have a query that takes about 10 seconds.
The strange thing is that if I replaced the machineNo parameter with a hardcoded integer (e.g. 3), the request will take a second. This is the most unusual performance issue I've encountered so far.
public static IEnumerable<vwJobAppointment> GetAllJobs(int machineNo)
{
var db = new DbContext();
IEnumerable<vwJobAppointment> list;
list = db.vwJobAppointments.Where(a => a.ResourceId == (machineNo)).AsNoTracking().ToList();
return list;
}
The request takes 10 seconds +
public static IEnumerable<vwJobAppointment> GetAllJobs(int machineNo)
{
var db = new DbContext();
IEnumerable<vwJobAppointment> list;
list = db.vwJobAppointments.Where(a => a.ResourceId == (3)).AsNoTracking().ToList();
return list;
}
This request takes less than a second.
Any ideas? I am using Entity Framework 5 with SQL 2008 database
source
share