简体   繁体   English

从本地数据库逆向GeoCode

[英]Reverse GeoCode from local database

We are using SQL Server 2008 web edition. 我们正在使用SQL Server 2008 Web版。 We have a table named "tbl_geodata" which has address and latitude and longitude values. 我们有一个名为“ tbl_geodata”的表,该表具有地址以及纬度和经度值。 We also have a "History" table which has only latitude and longitude values including other information. 我们还有一个“历史”表,其中仅包含经度和纬度值,包括其他信息。 What we need is like following... 我们需要的是以下内容...

We get a set of records based on a query from "History" (lat long values), say 5000 records 我们基于“历史记录”(纬度值长)的查询得到一组记录,例如5000条记录

Now we are using the following formula to calculate address from the "tbl_geodata" for each row (5000 rows). 现在,我们使用以下公式从“ tbl_geodata”为每行(5000行)计算地址。

SELECT top 1 geo_street,geo_town,geo_country,( 3959 acos( cos( radians(History.lat) ) cos( radians( gps_latitude ) ) cos( radians( gps_longitude ) - radians(History.long) ) + sin( radians(History.lat) ) sin( radians( gps_latitude ) ) ) ) AS distance FROM tbl_geodata ORDER BY distance

Currently we are seeing high cpu utilisation and performance issue. 目前,我们看到了较高的CPU使用率和性能问题。 Can anyone please suggest the improvement steps? 有人可以建议改善步骤吗?

You need a spatial index. 您需要一个空间索引。 See CREATE SPATIAL INDEX , and Spatial Indexes overview . 请参阅CREATE SPATIAL INDEX空间索引概述 Spatial indexes were introduced in SQL Server 2008, and Web Edition should allow them. 空间索引是在SQL Server 2008中引入的,Web Edition应该允许它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM