postgres空间索引 [英] postgres spatial indexing
问题描述
我似乎找不到这方面的文档。
在postgres上创建一个数据库/表的最简单的方法是支持像这样的查询SELECT * FROM table WHERE distance(POINT(0,0),table.location)< = 1000m;
其中POINT(0,0)和table.location应为纬度/经度对,1000m为1000米。我应该怎么去索引那张表呢?
谢谢。
PostgreSQL支持对表达式和部分索引的索引, >
这只是一个随机猜测,我不知道它是否可行,但试试:
CREATE INDEX foobar ON表(距离(POINT(0,0),位置))
WHERE距离(POINT(0,0),位置)<= 1000;
http://www.postgresql.org/docs/9.0/interactive/indexes-expressional.html
http://www.postgresql.org/docs/9.0/interactive /indexes-partial.html
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.
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:
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
这篇关于postgres空间索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!