Question

I've read a fair amount on this. but can't find a workable solution. I have a server with plenty of RAM and a 10GB DB. I want to load the entire DB (including indexes) into RAM/cache.

This solution doesn't seem to work: http://sqlsmurf.wordpress.com/2011/05/23/sql-warm-up-script/

Is there an way to load everything into RAM storage? I could do SELECT * FROM blah, however that (I believe) wouldn't work as it wouldn't load the indexes properly, it would also be somewhat slow.

Was it helpful?

Solution

When I need to bring something into cache (and there are use-cases for that, for example to shorten the time an offline index build takes), I use something like this:

SELECT COUNT_BIG(*)
FROM T WITH (NOLOCK, INDEX(IndexNameHere))
OPTION (MAXDOP 1)

And run that for each index. It doesn't get more efficient than this. The NOLOCK is there to get an IAM scan instead of a b-tree-order scan.

Still, I'd like to find out why you want this. The DB will be brought gradually into cache when it is being used. Basically on the first access to a page that page is cached. Isn't that enough?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top