When you try to build an index (by using CREATE INDEX or ALTER INDEX) on a spatial data type of a large table in Microsoft SQL Server 2012 or SQL Server 2014, the contention is high on the CMEMTHREAD wait type, and the performance of SQL Server decreases.
The issue was first fixed in the following cumulative update of SQL Server.
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:
A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem.
If the hotfix is available for download, there is a "Hotfix Download Available" section at the top of this Knowledge Base article. If this section does not appear, submit a request to Microsoft Customer Service and Support to obtain the hotfix.
Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft website:
Note The "Hotfix Download Available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.
A CMEMTHREAD wait type indicates the wait on the internal, thread-safe memory objects. Higher levels of query parallelism may trigger the wait that leads to decreased performance of the spatial activity.
This fix partitions the CMEMTHREAD that associates with the "Spatial Memory Object" by using NUMA node partitioning. This reduces the worker activity concurrency to the number of schedulers active on a single node. For systems with higher levels of schedulers per node, trace flag –T8048 can be used to further partition all memory objects that allow partitioning by scheduler. Use the trace flag carefully, as it introduces a small amount of memory overhead to all NUMA node-partitioned memory objects.
Note The spatial memory object is created when the SqlServerSpatial110.dll is loaded into the SQL Server process address space. In most conditions, this requires a restart of the SQL Server process in order to apply the trace flag effects.
The CMEMTHREAD wait type is incremented for any thread safe memory object wait, not just the spatial object. The following XEvent session definition and use of public symbols can be used to identify the specific code line that is generating CMEMTHREAD waits:
CREATE EVENT SESSION wait_stacksON SERVERADD EVENT sqlos.wait_info( action(package0.callstack) where opcode = 1 -- wait completed and wait_type = 191 -- CMEMTHREAD)add target package0.asynchronous_bucketizer (SET source_type = 1, source = 'package0.callstack'),add target package0.ring_buffer (SET max_memory = 4096)With (MAX_DISPATCH_LATENCY = 1 SECONDS)Goalter event session wait_stacks on server state = startgo Run the repro select event_session_address, target_name, execution_count, cast (target_data as XML)from sys.dm_xe_session_targets xst inner join sys.dm_xe_sessions xs on (xst.event_session_address = xs.address)where xs.name = 'wait_stacks'go
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.