I am using the following query to fetch road data from
Since i am using north-america database imported with osm2pgsql its taking upto 12 seconds. is there a way where i can optimize this and bring the time close to 1s? asked 07 Aug '17, 13:51 aitizazk |
You're unnecessarily computing the distance twice, but that's the least of your problems. Your query cannot make use of the geometry index on planet_osm_line because you are applying a geometry transformation to the way column. Every time you make this query, every single highway in North America is converted to EPSG:4326 by PostGIS. Instead, transform the reference point before you let PostGIS find nearby roads. Assuming your database is in EPSG:900913, that would be
This query returns near-instantly and gives you the same result. Note I have converted your 0.0009 degrees to approxmiately 100 Mercator units, YMMV. answered 07 Aug '17, 18:01 Frederik Ramm ♦ Woow thanks alot it drastically improved the performance and now results are returned in less than a second.. Awesome
(08 Aug '17, 08:04)
aitizazk
|
crosspost: https://gis.stackexchange.com/questions/251246/optimize-fetching-road-information-from-osm