【问题标题】:postgres spatial indexingpostgres 空间索引
【发布时间】:2010-10-15 18:09:06
【问题描述】:

我似乎找不到太多关于此的文档。 在postgres上创建数据库/表支持这样的查询的最简单方法是什么 SELECT * FROM table WHERE distance(POINT(0,0), table.location)

【问题讨论】:

    标签: sql database postgresql geolocation geospatial


    【解决方案1】:

    PostgreSQL 支持表达式索引和部分索引,你可以混合使用。

    这只是一个随机猜测,我不知道它是否有效,但请尝试一下:

    CREATE INDEX foobar ON table (distance(POINT(0,0), location))
     WHERE distance(POINT(0,0), location) <= 1000;
    

    http://www.postgresql.org/docs/9.0/interactive/indexes-expressional.html

    http://www.postgresql.org/docs/9.0/interactive/indexes-partial.html

    【讨论】:

    • 请记住,地球不是平的。这种平面计算在一般情况下效果不佳。
    【解决方案2】:

    您是否研究过 Postgis 和 contrib/earthdistance?

    http://www.postgis.org/

    http://www.postgresql.org/docs/9.0/interactive/earthdistance.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-07
      • 2012-11-03
      相关资源
      最近更新 更多