I'm currently using Microsoft Enterprise Library Data Access 5.0 to execute a stored procedure.
Database myDatabase = DatabaseFactory.CreateDatabase();
using (DbCommand command = myDatabase.GetStoredProcCommand("myStoredProc"))
{
//Add parameters here
using (IDataReader dataReader = myDatabase.ExecuteReader(command))
{
while (dataReader.Read())
{
}
}
}
Everything works however it takes a long time to run. When I turn on SQL Profiler, I can see the stored procedure takes about 50 seconds to run. However, if i take that same scripts from the Profiler and run it inside SQL Management Studio, it only takes about 480 miliseconds to return all the rows.
Has anyone run into this issue? Why is there a big difference?
Could easily be Parameter Sniffing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With