I've a simple update query (on two large tables) which does never finish.
UPDATE transit_edge te1 SET dates_to_add =
( SELECT ARRAY_AGG(date)
FROM transit_edge te2 LEFT OUTER JOIN calendar_dates cd2 ON (te2.service_id = cd2.service_id AND cd2.exception_type = 1)
WHERE te2.transit_edge_id = te1.transit_edge_id
);
If I only run the inner query with a given id, I get the correct result.
SELECT ARRAY_AGG(date)
FROM transit_edge te2 LEFT OUTER JOIN calendar_dates cd2 ON (te2.service_id = cd2.service_id AND cd2.exception_type = 1)
WHERE te2.transit_edge_id = te1.transit_edge_id AND te1.transit_edge_id = 282956
The table count is rather high:
select count(*) from transit_edge;
count
---------
9187885
select count(*) from calendar_dates;
count
----------
10025969
I also updated the postgresql.conf to enable larger memory usage.
#------------------------------------------------------------------------------
# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------
# - Memory -
shared_buffers = 2GB
work_mem = 200MB
checkpoint_segments = 3
max_connections = 100
maintenance_work_mem = 64MB
I ran the inner query with a limit of 100 and got the following error message
ERROR: invalid memory alloc request size 1073741824
Any help is kindly appreciated! Daniel
EXPLAINoutput for the query that never finishes?EXPLAIN? WithoutANALYZE? That suggests it's getting stuck in planning, and that shouldn't happen. Exact PostgreSQL version fromSELECT version()?EXPLAIN UPDATE ...hangs indefinitely? Is there anything relevant inpg_locks? Is the postgres backend (identified by runningSELECT pg_backend_pid()before running theEXPLAIN UPDATE ...) using 100% CPU?