[postgis-users] Poor Query Performance

elliott elliott at cpi.com
Mon Oct 31 06:46:24 PDT 2011

Hi All,

It is taking twice as long to do a single query for multiple lat/lon 
pairs ( 10,000 of them ) than to iterate over the pairs and query for 
each.  I would have thought that the single query would be faster.

The queries are as follows:
Called once:

select ST_Value(rast, ST_Transform(ST_SetSRID(ST_Point(s.lon, s.lat), 
4326), ST_SRID(rast))) from srtm3 cross join( VALUES (lat1,lon1), 
(lat2,lon2), (lat3,lon3), ... (lat10000, lon10000) ) as s(lat,lon) where 

Called for each lat/lon pair:

select ST_Value(rast, ST_Transform(ST_SetSRID(ST_Point(lon, lat), 4326), 
ST_SRID(rast))) from srtm3 where filename='N38E126.hgt';

More information about the postgis-users mailing list