开发者

automatically restart sql server after rebuild index

开发者 https://www.devze.com 2023-01-23 16:07 出处:网络
i want to automatically restart sql server after nightly rebuild index (in a 开发者_运维知识库job) to free memory.

i want to automatically restart sql server after nightly rebuild index (in a 开发者_运维知识库job) to free memory.

any solution?


You do not want to restart SQL Server to free memory. It is using memory to improve performance. Restarting it merely forces it to recache everything AGAIN at the cost of query performance.


A direct answer to your question would be to write a batch job:

net stop MSSQLSERVER
net start MSSQLSERVER

and schedule it in Windows Scheduler.

However, I wonder:

  1. Why do you need a nightly index rebuild at all?
  2. Which memory you want to free and why? DBCC DROPCLEANBUFFERS will purge the buffer pool which is the only thing that will be seriously affected, but why would you want to clean it?


It looks like you may be seeing poor performance from SQL Server as the server has stolen all the RAM from the Operating Systyem. Check that the total memory available to all instances of SQL server on your server leaves enough for the OS to work in RAM (4Gb or so).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号