Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9190

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

$
0
0

Kent,

It all depends on several factors.  Most obvious is if parameters are passed to the procedure that affect which or how many rows are evaluated and returned by the query.  More likely is it's simply a matter of the first execution having to get the data directly from disk using physical io and storing those rows in data cache.  The second execution comes along and finds all of the data in cache which is obviously much faster than disk io.  A stored procedure's query plan is stored in procedure cache and is most likely reused, so doubtful if the query plan is changed between executions.

 

Try using some "set" commands to illustrate this for you:

 

set statistics io on

go

exec myproc

go


Viewing all articles
Browse latest Browse all 9190

Trending Articles