I'm using PostGIS for the first time to calculate distances between two points, for a driving school booking system I am working on. I have loaded in all of the maps for Australia, but the query I wrote takes a good 5-6 seconds to execute. Most of the journeys are very short so I was thinking of using a bounding box but the relevant function (dijkstra_sp_delta) appears to be deprecated. Does anyone have any insight on how to implement this or speed up these kinds of functions more generally? I would like to get the query time down to 1 second or less.
SELECT SUM(
(SELECT ST_length(ST_Transform(the_geom,28355))
FROM ways w
WHERE w.gid = id2
)) as distance_in_metres
FROM pgr_dijkstra(
'SELECT gid AS id, source, target, ST_length(ST_Transform(the_geom,28355))/1000*60/maxspeed_forward AS cost
FROM ways', 247201, 298103, false, false);