Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
You could try if a LEFT JOIN is faster, but I think the PostGIS query analyzer should do a good job and figure it out anyway. –  underdark Aug 11 '12 at 9:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.