[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

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

aka e.g.
CLUSTER cities USING cities_way_gist;


More information about the postgis-users mailing list