We installed miniprofiler. It has been an edifying experience, but now we see that our database queries run 3x as fast with the profiler enabled as with it disabled.
The only code we changed in our app was to add the profiledDbConnection:
public static DbConnection GetOpenConnection(string connectionString)
{
var cnn = new System.Data.SqlClient.SqlConnection(connectionString);
// wrap the connection with a profiling connection that tracks timings
return MvcMiniProfiler.Data.ProfiledDbConnection.Get(cnn, MiniProfiler.Current);
}
Linq2Sql is suddenly...fast.
I'm not complaining, but why is this happening?
What do you mean by 'database queries run 3x faster'?
If it is case 1 than the difference will be in the SQL generated - compare both statements. If it is case 2 than run a C# profiler (Ants, dotTrace) and compare execution time of all the methods.
Difference of this magnitude will be related to a totally different path of execution - maybe you're not doing a heavy loop or you're getting data from cache.
First of all you can verify if you are hitting database at all and the number of queries is exactly the same.
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