I am using the following query to fetch road data from planet_osm_line
SELECT maxspeed, highway, ref, name,
ST_Distance(
ST_SetSRID(ST_Point(-98.224861,38.811898),4326),
ST_Transform(way, 4326)
) as distance
FROM planet_osm_line
WHERE highway is not null
AND ST_DWithin(
ST_SetSRID(ST_Point(-98.224861, 38.811898),4326),
ST_Transform(way, 4326),
0.0009
)
ORDER BY ST_Distance(
ST_SetSRID(ST_Point(-98.224861,38.811898),4326),
ST_Transform(way, 4326)
) LIMIT 1;
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?