Wednesday, June 2, 2010

Concise guide to SQL Server 2005 memory use over 4 GB on a 32-bit server

All of this information is from SQL Server Books on Line and MSDN; much is copyrighted by Microsoft.  The best single reference is http://msdn.microsoft.com/en-us/library/ms190731(v=SQL.90).aspx  There are many caveats – read and research before implementing.  This was done, and tested, for SQL Server 2005 running on Windows Server 2003.  The Click Commerce “Extranet” was running as well.  Some users do need to work directly on the server using Click programs.


1. Enable the Lock Pages in Memory Option - The Windows policy Lock Pages in Memory option is disabled by default. This privilege must be enabled to configure Address Windowing Extensions (AWE). This policy determines which accounts can use a process to keep data in physical memory, preventing the system from paging the data to virtual memory on disk. On 32-bit operating systems, setting this privilege when not using AWE can significantly impair system performance. Locking pages in memory is not required on 64-bit operating systems. Use the Windows Group Policy tool (gpedit.msc) to enable this policy for the account used by SQL Server 2005 Database Engine. You must be a system administrator to change this policy.
a. On the Start menu, click Run. In the Open box, type gpedit.msc.  The Group Policy dialog box opens.
b. On the Group Policy console, expand Computer Configuration, and then expand Windows Settings.  
c. Expand Security Settings, and then expand Local Policies.  
d. Select the User Rights Assignment folder.  The policies will be displayed in the details pane.  
e. In the pane, double-click Lock pages in memory.
f. In the Local Security Policy Setting dialog box, click Add.
g. In the Select Users or Groups dialog box, add an account
h. with privileges to run sqlservr.exe.


2. In SQL Server right-click a server and select Properties.  Click the Memory node.  Under Server Memory Options select Use AWE to allocate memory.   To use 6 GB of memory set Minimum server memory to 3072 (MB), and Maximum server memory to 5120 (MB).  Alternatively run these commands:
sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'awe enabled', 1
RECONFIGURE
GO
sp_configure 'min server memory', 3072
RECONFIGURE
GO
sp_configure 'max server memory', 5120
RECONFIGURE
GO
Restart SQL Server for these to take effect.


3. Edit the BOOT.INI file, and remove the /3GB switch, if present, and add the /PAE switch.  This requires a reboot to take effect. (Note: the 3GB switch only hurts if memory exceeds 16 GB)


(Comments appreciated)

1 comment:

  1. I reviewed this with CLICK Commerce in the context of a related problem, and they absolutely do not support the "Lock pages in memory" option because it can restrict Windows ability to flexibly manage memory. They do not have a feasible solution for using more then 4 GB of memory on a 32-bit server. And the solution above and other changes led to a significantly happier developers. Oh well.

    ReplyDelete