Home > SQL Server Tips > Database Administration > SQL Server memory configurations for procedure cache and buffer cache
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DATABASE ADMINISTRATION

SQL Server memory configurations for procedure cache and buffer cache


Denny Cherry, Contributor
06.09.2008
Rating: -4.22- (out of 5)


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


SQL Server allocates memory into two basic types of cache. The first is the memory most people are familiar with -- the buffer cache. That's where SQL Server stores data that it has loaded from the disk. With buffer cache, return trips to the disk are not necessary. The second type of memory is procedure cache. This is where SQL Server caches query execution plans it has run. The larger the procedure cache area, the more execution plans SQL Server can keep in memory, which reduces the amount of time the system takes to prepare the query for execution.

A procedure cache space that is too small is just as bad as having a buffer cache space that is too small. If it doesn't have enough space in the procedure cache to store all of the execution plans, SQL Server has to recreate the execution plans for the queries as they are run. That causes the CPU load on the SQL Server to go up. With the exception of joining tables on non-indexed columns, generating execution plans is about the most expensive operation SQL Server can perform.

Checking how much procedure cache is in use is not the easiest metric to measure. Microsoft has not provided many performance monitor counters related to the procedure cache. Unlike the buffer cache, which has a Page Life Expectancy counter that tells you how long data is expected to remain in memory, the procedure cache only has hit percentages that tell you how often SQL Server is able to find an execution plan in memory. The higher this number is, the better, because it means SQL Server has to generate execution plans less often.

SQL Server uses several methods to determine how much memory is used for the buffer cache and the procedure cache. The factors include the version of SQL Server that you're using, the amount of memory you've allocated to your SQL Server instance, and which platform you are using (x86, x64 or Itanium).

The 32-bit platform

The 32-bit platform (x86) has the least amount of bu


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Microsoft SQL Server Performance Monitoring and Tuning
Performance implications of transaction log autogrowth in SQL Server
The short course on how SQL Server really works
Determining the source of full transaction logs in SQL Server
Improving SQL Server full-text search performance
New GROUP BY option provides better data control in SQL Server 2008
Microsoft SQL Server 2008 Resource Governor primer
Examining data files when SQL Server tempdb is full
Testing transaction log autogrowth behavior in SQL Server
Meeting business needs with SQL Server full-text search
Using dynamic management views to improve SQL Server index effectiveness

SQL Server High Availability, Scalability and Reliability
Top load balancing methods for SQL Server
Maintaining high availability of SQL Server virtual machines
Creating fault-tolerant SQL Server installations
Scaling up vs. scaling out with SQL Server 2008
How to configure storage in SQL Server database with more writes than reads
SQL Server database replication tutorial
Licensing a standby server for SQL Server replication
Get SQL Server log shipping functionality without Enterprise Edition
Monitor database mirroring and replication after a SQL Server upgrade
Upgrade live applications to SQL Server 2005 for high availability
SQL Server High Availability, Scalability and Reliability Research

Database Administration
Setting up SQL Server Service Broker for secure communication
Top load balancing methods for SQL Server
Performance implications of transaction log autogrowth in SQL Server
The keys to database backup protection for SQL Server
Understanding transparent data encryption in SQL Server 2008
Working with sparse columns in SQL Server 2008
Determining the source of full transaction logs in SQL Server
Implementing SQL Server 2008 FILESTREAM functionality
Improving SQL Server full-text search performance
Using the OPENROWSET function in SQL Server

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
contiguity  (SearchSQLServer.com)
contiguous  (SearchSQLServer.com)
drilldown  (SearchSQLServer.com)
hashing  (SearchSQLServer.com)
hybrid online analytical processing  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


ffer cache. Procedure cache cannot reside within the Address Windowing Extension (AWE)-controlled memory space; it has to be in the first 2 Gigs of RAM allocated to the SQL Server instance. On the 32-bit platform SQL Server 2000 and SQL Server 2005, both use the same base calculation to find the amount of procedure cache to use. SQL Server will use up to 1 GB of memory, or 50% of the memory, whichever is lower.

The 64-bit platform

With the 64-bit platform (x64 or Itanium), things get a bit more complex.

SQL Server 2000 64-bit uses the same base calculations as the x86 edition of SQL Server 2000. With SQL Server 2005 64-bit, the build of SQL Server is also used to determine how much procedure cache will be used. SQL Server 2005 Service Pack 2 (build 9.00.3042) introduced some modifications to the method SQL Server uses to calculate the amount of procedure cache available. Microsoft made the change because of problems with some customers' SQL Servers allocating two much memory to the procedure cache and not leaving enough memory for the buffer cache. While this probably only affected a small number of customers, the platform needs to be able to support all customers.

Microsoft, unfortunately, didn't do a very good job of announcing the change, so there was a bit of a surprise when shops installed Service Pack 2 on machines with a very large amount of memory installed and that used a large amount of procedure cache.

In SQL Server 2005 SP1 and earlier, the system uses 75% of the first 8 Gigs of RAM + 50% of the next 56 Gigs of RAM + 25% of the remaining RAM. A SQL Server instance with 64 Gigs of RAM allocated to it could have a maximum of 34 Gigs of procedure cache allocated to it. A system with 12 Gigs of RAM could have a maximum of 8 Gigs of procedure cache allocated to it.

In SQL Server 2005 SP2 and later, the system uses 75% of the first 4 Gigs of RAM + 10% of the RAM over 4 Gigs. In the same system with 64 Gigs of RAM allocated to the SQL instance, SQL Server could have a maximum of 9 Gigs of RAM. A system with 12 Gigs of RAM could have a maximum of 3.8 Gigs of RAM for SQL Server.

You can see how systems that require large procedure caches would instantly show major performance issues after SQL Server 2005 Service Pack 2 was installed – the massive drop of procedure cache would cause those large systems to do thousands of additional recompiles that they didn't need to do previously.

Right now, no documentation has been released that shows how SQL Server 2008 will calculate the amount of procedure cache available to the database.

It is extremely important to know how much procedure cache is needed and also how SQL Server determines the maximum amount of procedure cache available. You should also know how this number would change as you install various service packs and patches to your production systems. Unfortunately, procedure cache issues -- like the change between service packs -- are hard to test in a non-production environment unless you have solid load-testing procedures in place where you can simulate a full system load in a non-production environment.

[TABLE]


Rate this Tip
To rate tips, you must be a member of SearchSQLServer.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SQL Server Development - .NET, C#, T-SQL, Visual Basic
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts