系统相关
首页 > 系统相关> > 【基本优化实践】【1.3】最大内存参数限制

【基本优化实践】【1.3】最大内存参数限制

作者:互联网

 

/* 规则
    如果16G及以下,给2G给操作系统
    如果32G及以下,给4G给操作系统
    如果32G以上(不含32G),给内存的10%给系统
*/

use master
go

declare @physical_memory int
declare  @TempTable table
(
[Index] VARCHAR(2000) ,
[Name] VARCHAR(2000) ,
[Internal_Value] VARCHAR(2000) ,
[Character_Value] VARCHAR(2000)
);
INSERT INTO @TempTable
EXEC xp_msver;
SELECT @physical_memory=cast(Internal_Value as int)
FROM @TempTable
WHERE Name = 'PhysicalMemory';
print @physical_memory
if @physical_memory<=1024*16
    set @physical_memory=@physical_memory-1024*2
else if @physical_memory<=1024*32
        set @physical_memory=@physical_memory-1024*4
    else
        set @physical_memory=@physical_memory*0.9

print @physical_memory
EXEC sys.sp_configure N'max server memory (MB)',@physical_memory
GO
RECONFIGURE WITH OVERRIDE
GO

 

标签:VARCHAR,32G,1.3,TempTable,2000,参数,内存,memory,physical
来源: https://www.cnblogs.com/gered/p/11063920.html