query slow then fast

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!

pae2
pae2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
surely because the data is cached in memory. It may be a sign of missing indexes
0
pae2Author Commented:
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.
0
Éric MoreauSenior .Net ConsultantCommented:
Pretty sure it is the cache. is it a complex query? an ad-hoc query or a SP?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pae2Author Commented:
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!
0
PortletPaulfreelancerCommented:
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)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.