You can create a query to select all edges within some distance of the start and end points and then only the major roads in the bbox between the the start and end points. So something like: select * from edges where st_dwithin(the_geom, start_pt, radius) union select * from edges where st_dwithin(the_geom, end_pt, radius) union select * from edges where st_expand(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4; As an alternative to the third select you could try: select * from edges where st_dwithin(st_buffer(st_setsrid(st_makeline(start_pt, end_point), st_srid(start_pt)), radius) && the_geom and road_class < 4; This will make a "sausage" of radius "radius" between the start and end and only select the segments the intersect with that sausage, you might need to increase the diameter by using something like 1.5*radius or 3.0*radius to make sure you are getting all the segments you need for the solution.