Reputation: 5594
I have a stored procedure which I call by
Int32 siteID = 1;
DateTime startDate date;
DateTime endDate date;
var result = this.datacontext.GetSummary(siteID, startDate, endDate);
This executes very slow with linq but in SSMS this is very quick.
When I change the SP to only accept a start date and in the SP Create the endDate by:
DECLARE @EndDate date
SET @EndDate = DATEADD(yy,1,@StartDate)
and then execute as below:
var result = this.datacontext.GetSummary(siteID, startDate);
The query is really fast again. I am passing in the exact values as what would be the EndDate.
Has anyone seen anything like this. The query without the end date passed in executes in 0 seconds. With the end date it takes 6 minutes.
Any suggestions would be greatly appreciated.
Upvotes: 0
Views: 989