zoukankan      html  css  js  c++  java
  • 【基本优化实践】【1.3】最大内存参数限制

    开启参数优化 

    exec sp_configure 'show advanced options', 1 reconfigure;
    exec sp_configure 'xp_cmdshell', 1 reconfigure;
    exec sp_configure 'Ad Hoc Distributed Queries', 1 reconfigure;
    exec sp_configure 'show advanced options', 0 reconfigure;
    GO

    /* 规则
        如果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
  • 相关阅读:
    ubuntu下mysql的安装
    useradd和adduser的区别
    C和指针之学习笔记(6)
    C和指针之学习笔记(5)
    C和指针之学习笔记(4)
    Centos 7搭建Gitlab服务器超详细
    .NET Core sdk和runtime区别
    .NET平台历程介绍
    GitLabCICD
    Jenkins+gitlab+msbuild
  • 原文地址:https://www.cnblogs.com/gered/p/11063920.html
Copyright © 2011-2022 走看看