2 つのデータセットを持つ
300 の地理座標のリスト
200 万を超える地理座標のリスト
リスト 1 の各エントリについて、半径 5 マイル以内にあるリスト 2 のエントリの数を数えようとしています。
euclidean
比較的短い距離しか扱っていないので、距離を使用することにしました。
これが私のコードです。実行するには永遠に時間がかかります。コードを改善する方法についての提案。
Select
DistFilter.storenumber,
count(companynumber) as sohoCount
from
(Select
UKStoreCoord.storenumber,
UKStoreCoord.latitude as SLat,
UKStoreCoord.longitude as SLng,
SohoCoordinates.companynumber,
SohoCoordinates.latitude,
SohoCoordinates.longitude
from UKStoreCoord, SohoCoordinates
where abs(UKStoreCoord.latitude - SohoCoordinates.latitude)<0.1 and abs(SohoCoordinates.longitude - UKStoreCoord.longitude)<0.1
group by
UKStoreCoord.storenumber,
UKStoreCoord.latitude,
UKStoreCoord.longitude,
SohoCoordinates.companynumber,
SohoCoordinates.latitude,
SohoCoordinates.longitude) as DistFilter
where (((Distfilter.latitude - Distfilter.SLat) * 69) ^2 + ((Distfilter.longitude - Distfilter.SLng) * 46) ^2) <25
group by
DistFilter.storenumber
乾杯