SqlServer内存优化与清理 电脑版发表于:2022/7/1 11:54 ![](https://img.tnblog.net/arcimg/hb/5c1471b6f75b444aaa04a0360d3ba658.png) >#SqlServer内存优化与清理 [TOC] tn2>可以通过下面的命令清理数据库中所有的缓存。 ```bash --清除存储过程缓存 DBCC FREEPROCCACHE --清除会话缓存 DBCC FREESESSIONCACHE --清除系统缓存 DBCC FREESYSTEMCACHE('All') --清除所有缓存 DBCC DROPCLEANBUFFERS GO --打开高级配置 exec sp_configure'show advanced options', 1 GO --设置最大内存MB 2G exec sp_configure 'max server memory', 2048 EXEC ('RECONFIGURE' ) --设置执行时间 WAITFOR DELAY '00:00:10' --关闭高级配置 exec sp_configure'show advanced options',0 GO ``` tn2>如果在设置最大内存的时候失败的话也可以按照以下操作进行设置。 ![](https://img.tnblog.net/arcimg/hb/7d6626ce56234f0282fbd72539fcfa1d.png) ![](https://img.tnblog.net/arcimg/hb/b1befcce5a8b450ca47f883939176bee.png)