我需要優化這個查詢,'因爲執行時間太長。我已經在geom(point)上構建了主要索引,但它們並沒有被不幸地使用。如何優化空間查詢?
select *, cast(st_distance_sphere(city_gis.point, tmp1.pnt) as int) as distance
from tmp1
inner join city_gis
on cast(st_distance_sphere(city_gis.point,tmp1.pnt) as int) between 0 and 60000
Here my query and execution plan
我猜''city_gis.point'的類型是'geometry(Point,4326)',對嗎? –
是的,你是對的。 – user3306125