query slow then fast

Posted on 2013-08-28
Medium Priority
Last Modified: 2013-08-28
I have a query that runs slow for the first execution that gets substantially faster for subsequent executions, i.e. without any modifications. The hardware is abundant and the I/O is very low. My theory is that the problem might be rooted with compilation. First, is that a valid theory? Second, how can one improve compilation, generally? I have no other details. So please just provide whatever you can.

Thanks so much!

Question by:pae2
  • 2
  • 2
LVL 71

Assisted Solution

by:Éric Moreau
Éric Moreau earned 2000 total points
ID: 39447429
surely because the data is cached in memory. It may be a sign of missing indexes

Author Comment

ID: 39447433
Are there any other ideas other than missing indexes? I came up with the same idea. I think missing indexes has some validity. I'm wondering if there's something else.
LVL 71

Accepted Solution

Éric Moreau earned 2000 total points
ID: 39447442
Pretty sure it is the cache. is it a complex query? an ad-hoc query or a SP?

Author Comment

ID: 39447448
I haven't seen it yet. Someone else wrote it. But I think it's going to be coming my way. The compilation suggestion was just an idea I put out there, hopefully with some merit. If you come up with something else, please post it. I will Accept as Solution though. Thanks!
LVL 49

Expert Comment

ID: 39447517
some (small) amount of effort/cost/time can be spent in evaluation of a SQL query
but caching is much more likely to be the cause of this symptom
(particularly if the I/O is slow)

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

586 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question