[postgis-users] Searching city by coordinates
karsten
karsten at terragis.net
Fri Feb 26 00:13:19 PST 2021
>>> Second question: which index should I create to speed these queries up?
Just an Index on the column "way"?
Yes that is the first and most important step.
If 'way' is the geometry column then create a gist (spatial) index and
also set a primary key
ALTER TABLE cities.way ADD CONSTRAINT cities_pkey PRIMARY KEY(id);
CREATE INDEX cities_way_gist
ON cities.way
USING gist
(geom);
You can also again more speed for some types of spatial queries by
clustering (physically re-ordering in the table )
the geometries on the spatial index see
https://postgis.net/workshops/postgis-intro/clusterindex.html
aka e.g.
CLUSTER cities USING cities_way_gist;
Best
KV
More information about the postgis-users
mailing list