我已经在Server 2016中的新空间库SqlGeography上运行了一些测试,根据微软的说法,这比以前的版本要快得多:
Server 2016 --它只是运行得更快:本机空间实现。应用Server 2016,方法和空间活动的广度更快,规模更大。没有任何应用程序或数据库更改,只有Server二进制更新显示了显著的改进。
然而,测试表明,新库比旧库慢。我已经用微软,Microsoft.SqlServer.Types发布的Nuget在Microsoft.SqlServer.Types上测试了它。我已经测试了版本11和版本14 ( Server 2016)。
为了让新的空间库更好地运行,我应该做些什么?
小型测试的源代码是:
var line1 = CreateLine(56, -4, 58, 16);
var line2 = CreateLine(58, -4, 56, 16);
for (int i = 0; i < 50000; i++)
{
var intersection = line1.STIntersects(line2);
var contains = line1.STBuffer(1000).STContains(line1);
}
public static SqlGeography CreateLine(double fromLat, double fromLon, double toLat, double toLon)
{
SqlGeographyBuilder constructed = new SqlGeographyBuilder();
constructed.SetSrid(4326);
constructed.BeginGeography(OpenGisGeographyType.LineString);
constructed.BeginFigure(fromLat, fromLon);
constructed.AddLine(toLat, toLon);
constructed.EndFigure();
constructed.EndGeography();
var line = constructed.ConstructedGeography;
return line;
}发布于 2017-06-20 10:04:09
在本文中,微软写道,Microsoft.SqlServer.Types不再在Server 2016的T代码中使用。https://blogs.msdn.microsoft.com/psssql/2016/03/03/sql-2016-it-just-runs-faster-native-spatial-implementations/
如何在SQL 2014中工作:
随着Server空间数据类型的成熟,我们发现非托管( Server)到托管(Microsoft.SqlServer.Types)到SqlServerSpatial###.dll (非托管)转换(PInvoke和PUnInvoke)可能成为可伸缩性的瓶颈
在SQL 2016中:
(T) Server 2016调用方法的本机实现,避免非托管到非托管转换,从而提高性能。
看来SQL 2016直接使用SqlServerSpatial###.dll,而且性能只在T代码中得到提高。
https://stackoverflow.com/questions/43818613
复制相似问题