Skip to Content
0
Former Member
Mar 19, 2014 at 01:13 AM

how to setup a query plan in effective at any time for SP or SQL query?

54 Views

I have a SP which include a group by SQL statement. It retrieve data from a couple of tables which are over 1G size,

When I run this SP at first time, it take more than 5 minutes to get the result. then I run it again and again, Finally, it become very quick, I can get the result within second.

Not sure why. I guess it is because of query plan.

How to make it running at first time to get result within second? How to force a better best query plan in effective at first time to run the query?

If the engine has better plan in memory, could it be lost at some point? because I have the complain from end user said some times it is fast, sometime it is very slow.

How to resolve this problem?