Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query performance

Status
Not open for further replies.

mcs1000

Programmer
Jul 3, 2007
26
0
0
GB
Why would a basic SQL query be slow (~50 secs) the first time it is run and then fast from then on?
 
Thanks for the response. Would this be consistent with only happening when the server is restarted and is there anything i could do to improve it.
 

It kind of depends on the query. Are you sorting, joining or grouping on non-indexed columns? It could be that an execution plan has to be created the first time the query runs after starting up.

Here's where i would start:
Run a tuning trace on your query after rebooting and see if it recommends any indexes.
Or
Try putting the query in a stored procedure. That will hold the execution plan.

 
the buffer is managed internally by the database engine, nothing you can really do about it either way.

Generally, it's best not to depend on it because the buffer can be cleared down for many reasons.

Actually, on a related note, does anyone know how to turn off the buffering?

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top