The pgRouting
pgr_drivingDistance
function returns only ids of road network vertices, but without ids of road edges in specific drive time.
To find this road edges I created the query:
SELECT all_roads.id, the_geom
FROM
(
SELECT e.id, e.the_geom
FROM tmp_ddist dd,
tmp_edge e
WHERE
e.target = dd.vertex
UNION
SELECT e.id, e.the_geom
FROM tmp_ddist dd,
tmp_edge e
WHERE
e.source = dd.vertex
) all_roads
GROUP BY all_roads.id, the_geom
HAVING COUNT(all_roads.id) = 2
Basically it finds road edges which have source and target vertices in set generated by pgr_drivingDistance
function and returns only those edges which have both source and target in this set.
Is there any way to optimize this query?