I'm using pgrouting shortest_path_astar with a complicated cost function. It gives back the edges, vertices and costs. I would like to get the total distance of this shortest path (i.e., the sum of lengths of edges, not the sum of costs of edges).
For now, I use:
SELECT SUM(t2.length) FROM ( SELECT edge_id FROM shortest_path_astar(..., TRUE, TRUE) ) as t1, routing.edges as t2 where t1.edge_id = t2.edge_id
Is it the most efficient way to get the distance? I need to run this query many times and I want to be sure to do it in the fastest way.