cevincheung
V2EX  ›  问与答

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

  •  
  •   cevincheung · Jan 16, 2015 · 1813 views
    This topic created in 4138 days ago, the information mentioned may be changed or developed.

    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

    Supplement 1  ·  Jan 18, 2015
    已解决。postgis果然没让人失望。


    <->操作符可以解决。
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2982 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 82ms · UTC 09:40 · PVG 17:40 · LAX 02:40 · JFK 05:40
    ♥ Do have faith in what you're doing.