postgres 空间索引
我似乎找不到太多这方面的文档。 在 postgres 上创建支持这样的查询的数据库/表的最简单方法是什么 SELECT * FROM table WHERE distance(POINT(0,0), table.location) <= 1000m; 其中 POINT(0,0) 和 table.location 应该是纬度/经度对,1000m 是 1000 米。我应该如何对该表建立索引? 谢谢。
I can't seem to find much documentation on this.
What's the simplest way to create a database/table on postgres supporting a query like this SELECT * FROM table WHERE distance(POINT(0,0), table.location) <= 1000m;
Where POINT(0,0) and table.location should be latitude/longitude pair, and 1000m is 1000 meters. And how should I go about indexing that table?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PostgreSQL 支持表达式索引和部分索引,您可以混合使用它们。
这只是一个随机猜测,我不知道它是否有效,但请尝试一下:
http://www.postgresql.org/docs/9.0/interactive/indexes-expressional.html
http://www.postgresql.org/docs/9.0/interactive/indexes-partial.html
PostgreSQL support indexes on expressions and also partial indexes, you can probably mix them.
This is just a random guess, I don't know if it works, but give it a try:
http://www.postgresql.org/docs/9.0/interactive/indexes-expressional.html
http://www.postgresql.org/docs/9.0/interactive/indexes-partial.html
您研究过 Postgis 和 contrib/earthdistance 吗?
http://www.postgis.org/
http://www.postgresql.org/docs/9.0/interactive/earthdistance.html
Have you looked into Postgis and contrib/earthdistance?
http://www.postgis.org/
http://www.postgresql.org/docs/9.0/interactive/earthdistance.html