我有一些大文件需要导入到PostgreSQL 11中。我使用以下命令从命令行导入文件:
\set content `type C:\sensors\201802091904.json`
create table t2 ( j jsonb );
insert into t2 values (:'content'); *** failure occurs here ***
select * from t2;
CREATE TABLE T (j jsonb);
INSERT INTO T SELECT jsonb_array_elements(j)::jsonb FROM T2;
以上步骤适用于我的测试文件,但是在使用实际生产大小的文件(300+ MB)时失败。文件只会增加大小。
执行insert into t2 values (:'content');
会导致以下结果:
ERROR: out of memory
DETAIL: String of 296579468 bytes is too long for encoding conversion.
不编写自定义代码,将JSON文件导入PostgreSQL时如何解决此错误?