I am trying to create a network of paths using pgr_dijkstra. I keep getting an invalid memory error:
ERROR: invalid memory alloc request size 1080000000
CONTEXT: SQL function "pgr_dijkstra" statement 1
SQL statement "SELECT *
FROM pgr_dijkstra('SELECT id, source, target, cost FROM p797.cost_lines', source_arr, target_arr, false)"
PL/pgSQL function inline_code_block line 10 at SQL statement
SQL state: XX000
I have adjusted work_mem up to 1.2GB in order to try and handle this query (I am sole user of the database). I thought that this would solve the memory error but it has not. Any ideas as to why I am still getting this error? The query works fine on small areas. The area I am trying to process now is very large.
DO
$$
DECLARE
source_arr text[];
target_arr text[];
BEGIN
SELECT array_agg(source) FROM source_locations INTO source_arr ;
SELECT array_agg(target) FROM target_locations INTO target_arr ;
DROP TABLE IF EXISTS dijkstra;
CREATE TABLE dijkstra AS
SELECT *
FROM pgr_dijkstra('SELECT id, source, target, cost FROM cost_lines', source_arr, target_arr, false);
END $$;
Version 2.6.2 of pgRouting
develop
branch of pgRouting, which holds the next major release version at the moment.work_mem
! apart from that, it won't have too much effect on a compound C level extension, since the query itself is trivial compared to what pgr does under the hood. maybe try limiting the graph by a slightly buffered bbox around the source and target; that would also boost overall performance.