frenchie
frenchie

Reputation: 51937

how long does a query take to run?

I want to time a query. How do I do that? I want to change the order of the WHERE operators to see what will produce the best results; is this the best way to do it? I'm using sql server and .net 4.

Thanks.

Upvotes: 1

Views: 5169

Answers (2)

Merlyn Morgan-Graham
Merlyn Morgan-Graham

Reputation: 59111

Depending on what you're doing, you might be able to simply use a Stopwatch class to do your timing:

var stopwatch = new Stopwatch();
stopwatch.Start();
// Execute your query here
stopwatch.Stop();
Console.WriteLine("Elapsed time for query: {0}", stopwatch.Elapsed);

Upvotes: 0

Adrian
Adrian

Reputation: 2923

Sql Server Profiler will give you the best measurement of query speed. It comes with the SQL Management Studio.

Upvotes: 2

Related Questions