V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
cevincheung
V2EX  ›  问与答

关于 PostGIS,难道是我的打开方式不对?

  •  
  •   cevincheung · 2015-01-16 12:51:45 +08:00 · 1516 次点击
    这是一个创建于 3536 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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

    第 1 条附言  ·  2015-01-18 01:28:24 +08:00
    已解决。postgis果然没让人失望。


    <->操作符可以解决。
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2624 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 09:52 · PVG 17:52 · LAX 02:52 · JFK 05:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.