Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

PostGIS doesn't use index for spatial query

$
0
0

I can’t get PostGIS 2.1 running on PostgreSQL 9.3.5 to use a spatial index even for the simplest queries. The whole dataset is 8 million points (population count grid from here http://sedac.ciesin.columbia.edu/data/set/gpw-v3-population-count), the table is created as

CREATE TABLE points (population DOUBLE PRECISION NOT NULL, location GEOGRAPHY(4326, POINT) NOT NULL)

and index is CREATE INDEX points_gix ON points USING GIST(location).

The queries are as simple as they get SELECT SUM(population) FROM points WHERE ST_Distance(location, ST_GeographyFromText('SRID=4326; POINT(0 0)')) < 1000.

PostgreSQL always uses Seq scan for it, I’ve tried a subset with 10000 points – still Seq scan. Any ideas?


Viewing all articles
Browse latest Browse all 1138

Trending Articles