I include this story just for interest
I was recently asked to look at spreadsheets that had a macro which
took 20minutes to run but sometimes would run in just one minute. I
diagnosed the problem as : The main part of the code took about a
minute to run but it had a database query which took 19 minutes. But
sometimes the database query took almost no time at all.
My initial observation was that if you re-ran the macro almost
immediately it was quicker - but very occaisionally it was quick on the
first run!
The reason : SQL2005 cached some query results and this query was used
in a number of processes. If I re-ran immediately it got the cached
dataset; but sometimes I would get the cached data from a different
process running the query.
regards
--
tony h
------------------------------------------------------------------------
tony h's Profile:
http://www.excelforum.com/member.php...o&userid=21074
View this thread:
http://www.excelforum.com/showthread...hreadid=553537