pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: andrew@tao11.riddles.org.uk
Subject: BUG #15321: XMLTABLE leaks memory like crazy
Date: Fri, 10 Aug 2018 23:33:55 +0000
Message-ID: <153394403528.10284.7530399040974170549@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15321
Logged by:          Andrew Gierth
Email address:      andrew@tao11.riddles.org.uk
PostgreSQL version: 10.5
Operating system:   any
Description:        

From a report on IRC:

XMLTABLE runs a lot of setup code in the per-query memory context -
resulting in allocations of copies of namespace names, other values, and
_multiple copies of the passed-in XML document_, which are not freed
anywhere.

Accordingly, virtually any lateral call to XMLTABLE on non-toy amounts of
data will blow up the server memory usage:

select count(*)
  from (select ('<rec xmlns="http://foobar">';
                ||
repeat('<obj><col1>foo</col1><col2>bar</col2></obj>',10+(i%10))
                || '</rec>')::xml as content
          from generate_series(1,1000000) i) s,
       xmltable(xmlnamespaces('http://foobar'; AS x),
                'x:obj'
                passing t.content
                columns col1 text path 'x:col1'
                columns col2 text path 'x:col2'
                );
-- uses about 6GB of RAM in my tests



view thread (20+ messages)  latest in thread

Message-ID: <153394403528.10284.7530399040974170549@wrigleys.postgresql.org>
Permalink:  ../153394403528.10284.7530399040974170549@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/153394403528.10284.7530399040974170549@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, andrew@tao11.riddles.org.uk
  Subject: Re: BUG #15321: XMLTABLE leaks memory like crazy
  In-Reply-To: <153394403528.10284.7530399040974170549@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox