SQL
select
*,
st_distance_sphere(
geometry(poi),
geometry('POINT(116.41739 39.913164)')
) distance
from
test
order by
distance asc
limit
10
EXPLAIN结果:
Limit (cost=14826.00..14826.02 rows=10 width=51)
-> Sort (cost=14826.00..14950.85 rows=49939 width=51)
Sort Key: (_st_distance(geography(geometry(poi)), '0101000020E61000005BEB8B84B61A5D4039F1D58EE2F44340'::geography, 0::double precision, false))
-> Seq Scan on test (cost=0.00..13746.83 rows=49939 width=51)
已经给poi建立了gist索引了……为啥却没用呢?
才5w数据,检索却要0.2s