我是PostgreSQL的新手。我正在制作一个数据库,但我的XML文件有问题。这个XML文件有986MB或1029949618字节,我尝试了一些脚本,但出现了如下错误:
Error: out of memory
Detail: String of 1029949618 bytes is too long for encoding conversion.如何修复它?请帮帮我。
这是我尝试过的脚本:
create or replace function xml_import(filename text)
returns xml
volatile
language plpgsql as
$f$
declare
content bytea;
loid oid;
lfd integer;
lsize integer;
begin
loid := lo_import(filename);
lfd := lo_open(loid,1029949618);
lsize := lo_lseek(lfd,0,2);
perform lo_lseek(lfd,0,0);
content := loread(lfd,lsize);
perform lo_close(lfd);
perform lo_unlink(loid);
return xmlparse(document convert_from(content,'WIN1251'));
end;
$f$;
select xml_import('D:\SQLregisterUkr\15.1-EX_XML_EDR_UO.xml');发布于 2018-11-27 03:35:26
您不能在数据库中合理地拥有这样一个大小的xml。它低于1 1GB的理论限制,但正如您注意到的,问题开始得更早,因为整个对象必须驻留在RAM中。
无论如何,您都不能在PostgreSQL中合理地处理这种大小的XML。
如果您只想存储大文件,那么要么不将其存储在数据库中,要么使用大对象。
https://stackoverflow.com/questions/53485726
复制相似问题