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

3
  • Would you be able to try the current develop branch of pgRouting, which holds the next major release version at the moment.
    – dkastl
    Commented Sep 27, 2019 at 2: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
    Commented Sep 27, 2019 at 7: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
    Commented Sep 27, 2019 at 15:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.