1

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

D_C
  • 1,359
  • 10
  • 23
  • Would you be able to try the current develop branch of pgRouting, which holds the next major release version at the moment. – dkastl Sep 27 '19 at 02:28
  • as a general note: when encountering memory errors you likely want to decrease 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. – geozelot Sep 27 '19 at 07:08
  • I will give the develop a shot. I figured increasing the work_mem would give it access to more memory which is what is seems to be after. Are there any database settings that I can play with to make the memory alloc request size valid? – D_C Sep 27 '19 at 15:01

0 Answers0