In this post I will be looking at some useful tools and configuration changes that can be implemented to ensure that you get the best out of SQL:
- Run the Microsoft SQL Server 2008 R2 Best Practices Analyzer (Click Here)
- Split SQL TempDB per number of Processor Core (Click Here)
- Lock Pages in Memory
- Set SQL max memory limit
- Enable paging file
- Prevent Cluster Failover if SQL Server Agent resource fails
- Change recovery model to simple
- Exclude the following SQL file extension from Anti-Virus scan ‘LDF/MDF/NDFSQL’
1. Lock pages in memory: You only need to do this if you start noticing a significant part of SQL server processes been page out. Note: its best not to set this if your SQL servers are virtual machines to avoid resource contention with the Hypervisor.
- Click Start -> Run -> Type ‘gpedit.msc’
- On the Group Policy console -> Expand Computer Configuration -> Expand Windows Settings -> Expand Security Settings -> Expand Local Policies -> Double-click ‘Lock pages in memory‘
- On Lock pages in memory properties -> click Add user or group -> Enter your SQL service account -> click OK
2. Set SQL max memory limit: It’s best practice to set the max memory SQL can use most especially if you have enabled ‘Lock pages to memory‘. This will prevent SQL from using up all memories when under pressure to prevent it from starving other resources like the operating system and applications.
- Click on Start -> All Programs -> Microsoft SQL Server 2008 R2 -> SQL Server Management Studio
- On Connect to server screen -> Ensure Server type is Database Engine -> Server name is ‘SQL cluster name\instance name‘ if instance name is not default -> Select Windows Authentication as the authentication -> click Connect
- Right-click SQL instance and click Properties
- On Server properties page -> click Memory on left -> Set the max memory in MB. Please use the table below to set the memory based on the amount of memory installed on the server. Note less memory will need to be allocated to SQL if you have other SQL components installed like SSIS, SSRS etc.
Physical Memory | Max Memory Settings |
---|---|
2GB | 1500MB |
4GB | 3200MB |
6GB | 4800MB |
8GB | 6400MB |
12GB | 1000MB |
3. Enable Pagefile: Pagefile is useful for advance troubleshooting to capture a crash dump file when SQL crashes. Note also that when memory is committed, physical pages of memory are allocated and space is reserved in a pagefile.
- Click on Start -> Right-click ‘Computer’ and click properties
- Click Advance system settings -> On systems Properties click Advanced tab -> click Settings under Performance section -> On Performance Options click Advanced tab -> click Change
- On Virtual Memory screen -> Uncheck ‘Automatically manage paging file size for all drives‘ -> Select the system drive -> Select ‘Custom size’ -> Enter the page file size in MB
- Click OK and reboot the system
4. Prevent Cluster Failover if SQL Server Agent resource fails: When you install a SQL instance, the following resources are present in the SQL Server resource group:
The Server Name comprising of SQL cluster network name and IP address The disk drives that stores SQL data/log files Analysis service (if analyses component was installed) SQL server resource SQL server agent resource |
---|
The only resource that technically does not impact SQL operation is the SQL Server Agent. If the SQL Server Agent resource fails, scheduled jobs such as backups,database maintenance, and replication jobs will not run. I would recommend you prevent failure of this resource from failing over the whole resource group.
- Click on Start -> Administrative Tools -> Failover Cluster Manager
- Expand Failover Cluster Manager -> Expand NTClus service -> Expand Services and Applications -> click on the SQL Server resource group -> Right-click on ‘SQL Server Agent’ and click properties
- On SQL Server Agent properties -> click Policies tab -> Uncheck ‘If restart is unsuccessful, fail over all resources in this service or application‘ -> click OK
5. Change Model database recovery mode: When SQL is installed the ‘model‘ database recovery mode is set to FULL by default. Since creation of new databases uses the ’model‘ database as template, we need to change the recovery mode to SIMPLE if you use simple mode as your preferred recovery mode.
- Log into SQL via SQL Server Management Studio
- Expand SQL instance -> Expand Databases – Expand System Databases -> Right-click Model Database and click properties
- On the Model DB properties -> click Options -> Under ‘Recovery model’ click the drop-down and select Simple -> click OK to close
6. Anti-Virus Exclusion List: Microsoft recommends when configuring your antivirus software settings, ensure the folder directories and file extensions listed out below are exclude from virus scanning. Doing this improves the performance of the files and helps make sure that the files are not locked when the SQL Server service needs to use them or sometimes this might cause data corruption.
SQL Server data files extensions: “.mdf, .ldf, .ndf”
SQL Server backup files extensions: “.bak, .trn”
Others:
- Cluster drives (Quorum)
- MSDTC directory
- Cluster directory (%systemroot%\Cluster)
- Full-Text catalog files
- The directory that holds Analysis Services data
In my next SQL post, I will be looking at installing additional SQL instance in an existing SQL cluster and assign a different port for accessing the instance.