FIX: High CPU consumption when you use spatial data type and associated methods in SQL Server 2012 or SQL Server 2014

Applies to: SQL Server 2014 EnterpriseSQL Server 2014 EnterpriseSQL Server 2014 Developer


When you use the spatial data type and associated methods in Microsoft SQL Server 2012 or Microsoft SQL Sever 2014, the SQL Server Operating System (SQLOS) scheduler’s quantum targets are protected by the SQL Server CLR hosting layer. This protection involves preemptive, SQLOS switches may increase the CPU consumption. The reason for the preemptive switch is to protect the SQLOS scheduler. A call into a SQL Server CLR based implementation can take unspecified time without yielding to the SQLOS scheduler or changing the behavior and concurrency patterns. Therefore, the spatial data type is designed to switch preemptive during each invocation.

Note The spatial data type is based on SQL Server CLR, it may encounter various levels of .NET memory consumption and thread switching behavior.


The spatial data type methods executions are usually sub-millisecond and may not require the full SQL OS scheduler and preemptive protection. The overhead of switching to and from preemptive mode can be much larger than the execution of the spatial method itself.


This fix introduces the trace flag 6531 to indicate to the SQLOS hosting layer that the spatial data type should avoid preemptive protections. This can reduce the CPU consumption and improve the overall performance for spatial activities. Only use this trace flag if the individual, spatial method invocations (per row and column) take less than ~4ms. Longer invocations without preemptive protection could lead to scheduler concurrency issues and SQLCLR punishment messages logged to the error log.

The issue was first fixed in the following cumulative update of SQL Server.

Cumulative Update 4 for SQL Server 2012 SP2

Cumulative Update 5 for SQL Server 2014

Cumulative Update 13 for SQL Server 2012 SP1


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