我有表“test”,我用这个查询创建它:
CREATE TABLE test
(
id bigint,
str1 timestamp without time zone,
str2 text,
str3 text
);
创建表后,我添加了数据:
INSERT INTO test VALUES (1, '2017-08-29 10:51:40.190913', 'gfsdfg1', 'sfgsdhgy1');
INSERT INTO test VALUES (2, '2016-08-29 10:51:40.190913', 'gfsdfg2', 'sfgsdhgy2');
INSERT INTO test VALUES (3, '2015-08-29 10:51:40.190913', 'gfsdfg3', 'sfgsdhgy3');
INSERT INTO test VALUES (4, '2014-08-29 10:51:40.190913', 'gfsdfg4', 'sfgsdhgy4');
INSERT INTO test VALUES (5, '2013-08-29 10:51:40.190913', 'gfsdfg5', 'sfgsdhgy5');
INSERT INTO test VALUES (6, '2012-08-29 10:51:40.190913', 'gfsdfg6', 'sfgsdhgy6');
INSERT INTO test VALUES (7, '2011-08-29 10:51:40.190913', 'gfsdfg7', 'sfgsdhgy7');
INSERT INTO test VALUES (8, '2010-08-29 10:51:40.190913', 'gfsdfg8', 'sfgsdhgy8');
INSERT INTO test VALUES (9, '2009-08-29 10:51:40.190913', 'gfsdfg9', 'sfgsdhgy9');
INSERT INTO test VALUES (10, '2008-08-29 10:51:40.190913', 'gfsdfg10', 'sfgsdhgy10');
INSERT INTO test VALUES (11, '2009-08-29 10:51:40.190913', 'gfsdfg11', 'sfgsdhgy11');
INSERT INTO test VALUES (12, '2015-08-29 10:51:40.190913', 'gfsdfg12', 'sfgsdhgy12');
INSERT INTO test VALUES (13, '2020-08-29 10:51:40.190913', 'gfsdfg13', 'sfgsdhgy13');
然后我们尝试使用这样的查询更新此表:
UPDATE test SET
str1 = c.str1,
str2 = c.str2,
str3 = c.str3
FROM (
VALUES
(10, '2017-08-29 11:11:37'::timestamp without time zone, 'str2-10', 'str3-10'),
(11, '2017-08-29 11:11:37'::timestamp without time zone, 'str2-11', 'str3-11'),
(12, '2017-08-29 11:11:37'::timestamp without time zone, 'str2-12', 'str3-12'),
(13, '2017-08-29 11:11:37'::timestamp without time zone, 'str2-13', 'str3-13')
) AS c (id, str1, str2, str3)
WHERE c.id = test.id;
我得到了错误:
错误:无效的内存分配请求大小1610613056(上下文'ExecutorState')(mcxt.c:1069)(mcxt.c:477)(seg0 node03:40000 pid = 113577)(cdbdisp.c:1322)
如何解决此错误?
答案 0 :(得分:0)
您使用的是哪个版本的GPDB?
有一些已知的计划程序错误 - 这看起来像旧的遗留计划程序问题。
您可以尝试使用set optimizer=on;
或关闭吗?
由于内存分配的大小很大,因此表格统计数据导致计划程序爆炸的可能性更大。
作为最佳做法,请使用CREATE
跟踪每个ANALYZE
。
ANALYZE
表再次运行查询。