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.

有帮助吗?

解决方案

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?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top