FIX: CMEMTHREAD waits occur when you execute many ad hoc queries in SQL Server 2012 or SQL Server 2014

Platí pro: SQL Server 2012 EnterpriseSQL Server 2012 DeveloperSQL Server 2012 Express


Assume that you have many statistics and tables and the tables contain many columns in a Microsoft SQL Server 2012 or SQL Server 2014 database. When you execute many ad hoc queries to retrieve data from those tables concurrently, you may experience CMEMTHREAD waits during the execution.

More Information

When you compile or recompile a query in SQL Server 2012, the engine needs to get inputs from statistics histogram. We need to perform a system table scan and then load the specific histogram of the tables that are involved into memory or cache. These system table entries (for the statistics) are stored in the System Table cache (CACHESTORE_SYSTEMROWSET). The memory object that is used to create these entries in the cache is not partitioned, and is global.

Therefore, if you have concurrent memory allocations performed during this operation, you will encounter CMEMTHREAD waits on this memory object. This usually happens when you submit lots of queries that require compilation or recompilation.

This hotfix changes the global memory object to be partitioned so that concurrent memory allocations that use the System Table cache will not encounter contention and the CMEMTHREAD waits.

For more information about the similar issue, see KB 3026082: FIX: SOS_CACHESTORE spinlock contention on system table rowset cache causes high CPU usage in SQL Server 2012 or 2014 .


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.