简体   繁体   中英

Which PostGIS SRID is most efficient for a spatial index?

I have a PostGIS-enabled database with a table called locations that stores latitude-longitude points (SRID 4326) in a column called coordinates . However, all of my lookups on that table convert the points to a metric projection (SRID 26986) mainly to do distance comparisons.

Obviously I'd like to create a spatial index on the coordinates column. My question is, which is the best (most computationally efficient) SRID to use in the coordinates spatial index in this case?

I can either index using SRID 4326...

CREATE INDEX locations_coordinates_gist 
ON locations 
USING GIST (coordinates);

Or using SRID 26986...

CREATE INDEX locations_coordinates_gist 
ON locations 
USING GIST (ST_Transform(coordinates, 26986));

I discovered this helpful information reading the PostGIS documentation on the ST_Transform function...

If using more than one transformation, it is useful to have a functional index on the commonly used transformations to take advantage of index usage.

So it seems the answer is, use both! I have created two indices, one with each SRID.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM