分类: SQLServer
设置SQL Server最大内存使用量

SQLServer2008版本默认安装以后内存最大使用量为2147483647,基本会把系统内存耗尽,查看当前内存使用情况:

SELECT 
  physical_memory_in_use_kb/1024 AS sql_physical_memory_in_use_MB, 
    large_page_allocations_kb/1024 AS sql_large_page_allocations_MB, 
    locked_page_allocations_kb/1024 AS sql_locked_page_allocations_MB,
    virtual_address_space_reserved_kb/1024 AS sql_VAS_reserved_MB, 
    virtual_address_space_committed_kb/1024 AS sql_VAS_committed_MB, 
    virtual_address_space_available_kb/1024 AS sql_VAS_available_MB,
    page_fault_count AS sql_page_fault_count,
    memory_utilization_percentage AS sql_memory_utilization_percentage, 
    process_physical_memory_low AS sql_process_physical_memory_low, 
    process_virtual_memory_low AS sql_process_virtual_memory_low
FROM sys.dm_os_process_memory;  

SQL.png
设置当前最大内存使用量为16G

sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE;  
GO  
sp_configure 'max server memory', 16384;  
GO  
RECONFIGURE;  
GO

直接在SQL查询器里面执行即可,一般根据系统内存大小设置,至少保留2--3G内存给操作系统使用;
参考:https://docs.microsoft.com/zh-cn/sql/database-engine/configure-windows/server-memory-server-configuration-options?view=sql-server-2017
也可以在登陆SQLServer以后,右键服务器属性--内存,选择使用AWE分配内存、最小服务器内存、最大服务器内存等参数,如下图,最后确定即可;
memery.png


相关博文:

发表新评论