Answer the question
In order to leave comments, you need to log in
How to calculate the execution time of SQL queries?
It is necessary to calculate the execution time of sql queries, but sometimes my timing function returns 0, despite the fact that the query is quite normal and returns some result...
public double GetQueryTime(string query)
{
TimeSpan duration;
DateTime start = DateTime.Now;
cmd = new MySqlCommand(query, con);
using (MySqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read()) { };
}
duration = DateTime.Now.Subtract(start);
return duration.TotalMilliseconds;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question