我有一个简单的更新查询(在两个大表上),它永远不会完成。
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
);如果我只使用给定的id运行内部查询,则得到正确的结果。
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桌数相当高:
select count(*) from transit_edge;
count
---------
9187885
select count(*) from calendar_dates;
count
----------
10025969我还更新了postgresql.conf以启用更大的内存使用量。
#------------------------------------------------------------------------------
# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------
# - Memory -
shared_buffers = 2GB
work_mem = 200MB
checkpoint_segments = 3
max_connections = 100
maintenance_work_mem = 64MB我以100为限运行内部查询,并得到以下错误消息
ERROR: invalid memory alloc request size 1073741824任何帮助都是非常感谢的!丹尼尔
发布于 2014-09-29 08:30:38
试着使用这样的方法:
UPDATE transit_edge te1 SET dates_to_add =
( SELECT ARRAY_AGG(date)
FROM calendar_dates cd2
WHERE te1.service_id = cd2.service_id AND cd2.exception_type = 1
);https://stackoverflow.com/questions/26095469
复制相似问题