- An application runs a query that references some temporary tables in Microsoft SQL Server 2008 and in Microsoft SQL Server 2008 R2. The temporary tables are created in a session instead of in a stored procedure.
- The query plan is cached.
- Many users run the same query in a highly concurrent environment.
For example, many users use an application that runs the following query:create table #x (col1 int) go insert into #x values (1) go select * from #x where col1 = 1 go
Note For more information about how to identify this issue, see the "More information" section.
When a large number of plans are hashed to the same bucket (also known as a hash chain), the time to look up a plan in the cache increases significantly, and the performance issues may occur. Additionally, worker threads may encounter severe spinlock contention, and other threads are affected when these worker threads do not perform the correct scheduler yields.
Cumulative update information
SQL Server 2008 R2 Service Pack 1The fix for this issue was first released in Cumulative Update 1 for SQL Server 2008 R2 Service Pack 1. For more information about how to obtain this cumulative update package, click the following article number to view the article in the Microsoft Knowledge Base:
SQL Server 2008 R2The fix for this issue was first released in Cumulative Update 7. For more information about how to obtain this cumulative update package for SQL Server 2008 R2, click the following article number to view the article in the Microsoft Knowledge Base:
Spinlock contention can be identified from the sys.dm_os_spinlock_stats dynamic management view (DMV) that has a high contention rate on the SOS_CACHESTORE spinlock.
To identify this issue, run a query that resembles the following:
select cp.bucketid, count(cp.bucketid) as BucketCount, st.text from sys.dm_exec_cached_plans cp cross apply sys.dm_exec_sql_text(cp.plan_handle) as st group by cp.bucketid, st.text having count(cp.bucketid) >1 order by BucketCount desc
- This query generates the same query text.
- The count for the same bucketid is large.
Note A large count for the same bucketid is usually over 1000.
- The queries reference temporary tables
Article ID: 2526959 - Last Review: Jul 18, 2011 - Revision: 1