Questions tagged «st-dwithin»

2
ST_Distance不使用索引进行空间查询
即使对于最简单的查询,我也无法在PostgreSQL 9.3.5上运行PostGIS 2.1来使用空间索引。在整个数据集为800万点(人口数电网从这里)。该表创建为 CREATE TABLE points ( population DOUBLE PRECISION NOT NULL, location GEOGRAPHY(4326, POINT) NOT NULL ) CREATE INDEX points_gix ON points USING GIST(location); 查询很简单 SELECT SUM(population) FROM points WHERE ST_Distance( location, ST_GeographyFromText('SRID=4326; POINT(0 0)') ) < 1000 PostgreSQL总是使用Seq扫描,我尝试了10000点的子集-仍然是Seq扫描。有任何想法吗?

1
使用PostGIS查找给定2点的最近线?
我有一个表t,其中包含一列line_positionsline类型的列。给定2个点,我想找到最接近的直线,该直线足够接近(小于10公里)并且距离我想要避免的点(最小20公里)的距离不太远。目前我使用 SELECT t.* FROM path t WHERE ST_DWithin(ST_GeographyFromText('Point(69.835 22.596)'), t.line_positions, 10000, FALSE) AND ST_DWithin(ST_GeographyFromText('Point(69.856 22.519)'), t.line_positions, 10000, false) AND NOT ST_DWithin(ST_GeographyFromText('Point(-79.804 9.141)'), t.line_positions, 20000, false) ORDER BY ST_Distance(ST_GeographyFromText('Point(69.835 22.576)'), t.line_positions, false) + ST_Distance(ST_GeographyFromText('Point(69.856 22.519)'), t.line_positions, false) ASC LIMIT 1 ix_path_line_positionsline_positions列上有一个要点索引。 它有效,但速度很慢,在t中仅100000行在3s到30s之间。 解释分析给出: Limit (cost=9.95..9.95 rows=1 width=1432) (actual time=21729.253..21729.254 rows=1 loops=1) …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.