【问题标题】:PostgreSQL big XML file parsePostgreSQL 大 XML 文件解析
【发布时间】:2018-11-26 16:54:52
【问题描述】:

我是 PostgreSQL 的新手。我正在创建一个数据库,但我遇到了一个 XML 文件的问题。此 XML 文件有 986 MB 或 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');

【问题讨论】:

    标签: xml postgresql bigdata large-files


    【解决方案1】:

    您不能合理地在数据库中拥有如此大小的xml。它低于 1GB 的理论限制,但正如您所注意到的,问题开始得早得多,因为整个对象必须驻留在 RAM 中。

    无论如何,您都无法在 PostgreSQL 中合理地处理这种大小的 XML。

    如果您只想存储大文件,请不要将其存储在数据库中或使用大对象。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-09
      • 2020-08-19
      • 2017-05-04
      • 2014-07-22
      • 1970-01-01
      • 1970-01-01
      • 2020-10-16
      • 2015-09-15
      相关资源
      最近更新 更多