I have a stored procedure that when is executed directly against the database takes 1 second to run. It returns 46 rows of data.
The stored procedure is executed in code for my web site and returns data to create a report.
This works exactly as expected locally, takes a very short time (1/2 seconds) to load the report. When the web site is first deployed the report works as expected.
However, after a period of time (roughly half an hour) the report does not load because the stored procedure is timing out.
To get around this, if I drop and create the procedure it will start working again, but this is obviously not a solution to my problem.
The stored procedure is called in code like this:
DataSet content = new DataSet();
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmdSearchQuestionLibrary = db.GetStoredProcCommand("SP_NAME");
db.AddInParameter(cmdSearchQuestionLibrary, "@Param1", DbType.Int64, Id);
db.AddInParameter(cmdSearchQuestionLibrary, "@StartDate", DbType.DateTime, dtStartDate);
db.AddInParameter(cmdSearchQuestionLibrary, "@EndDate", DbType.DateTime, dtEndDate);
content = db.ExecuteDataSet(cmdSearchQuestionLibrary);
Has anyone experienced this before? Or know what could be causing the issue?