From: Tom Lane <tgl@sss.pgh.pa.us>
To: Brian Crowell <brian@fluggo.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Ted Toth <txtoth@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: large numbers of inserts out of memory strategy
Date: Tue, 28 Nov 2017 22:59:51 -0500
Message-ID: <26623.1511927991@sss.pgh.pa.us> (raw)
In-Reply-To: <CAAQkdDoq2fXk+E1gtVh_rUuJ99iLGrbc7jWBNkZpGHjytf-3NA@mail.gmail.com>
References: <CAFPpqQGux3uT=CNN-z=zXr4qSmfBw9tDCURimELqEWUBrBpL7A@mail.gmail.com>
<ad918f32-4913-3dee-281a-5a3fee576a14@2ndquadrant.com>
<CAFPpqQHY39wDEQm7JeBD6JSN_UgNi-19kdGdZKmhQ2gxTpw8Qw@mail.gmail.com>
<87d5d3c9-66e4-c29d-bece-79f2909cccb9@2ndquadrant.com>
<CAFPpqQGJ9GkntRrjEqvHCRtkbHojmTy93LmCpfuMGJj5F2O7-A@mail.gmail.com>
<8431416a-2ab2-d580-19bd-2c7e3353960d@2ndquadrant.com>
<CAAQkdDoq2fXk+E1gtVh_rUuJ99iLGrbc7jWBNkZpGHjytf-3NA@mail.gmail.com>
Brian Crowell <brian@fluggo.com> writes:
> On Tue, Nov 28, 2017 at 12:38 PM, Tomas Vondra <tomas.vondra@2ndquadrant.com
>> wrote:
>> So what does the script actually do? Because psql certainly is not
>> running pl/pgsql procedures on it's own. We need to understand why
>> you're getting OOM in the first place - just inserts alone should not
>> cause failures like that. Please show us more detailed explanation of
>> what the load actually does, so that we can try reproducing it.
> Perhaps the script is one giant insert statement?
It's pretty clear from the memory map that the big space consumption
is inside a single invocation of a plpgsql function:
SPI Proc: 2464408024 total in 279 blocks; 1672 free (1 chunks); 2464406352 used
PL/pgSQL function context: 537911352 total in 74 blocks; 2387536 free (4 chunks); 535523816 used
So whatever's going on here, there's more to it than a giant client-issued
INSERT (or COPY), or for that matter a large number of small ones. What
would seem to be required is a many-megabyte-sized plpgsql function body
or DO block.
Actually, the truly weird thing about that map is that the "PL/pgSQL
function context" seems to be a child of a "SPI Proc" context, whereas
it's entirely clear from the code that it ought to be a direct child of
TopMemoryContext. I have no idea how this state of affairs came to be,
and am interested to find out.
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, brian@fluggo.com, tomas.vondra@2ndquadrant.com, txtoth@gmail.com
Subject: Re: large numbers of inserts out of memory strategy
In-Reply-To: <26623.1511927991@sss.pgh.pa.us>
References: <CAFPpqQGux3uT=CNN-z=zXr4qSmfBw9tDCURimELqEWUBrBpL7A@mail.gmail.com> <ad918f32-4913-3dee-281a-5a3fee576a14@2ndquadrant.com> <CAFPpqQHY39wDEQm7JeBD6JSN_UgNi-19kdGdZKmhQ2gxTpw8Qw@mail.gmail.com> <87d5d3c9-66e4-c29d-bece-79f2909cccb9@2ndquadrant.com> <CAFPpqQGJ9GkntRrjEqvHCRtkbHojmTy93LmCpfuMGJj5F2O7-A@mail.gmail.com> <8431416a-2ab2-d580-19bd-2c7e3353960d@2ndquadrant.com> <CAAQkdDoq2fXk+E1gtVh_rUuJ99iLGrbc7jWBNkZpGHjytf-3NA@mail.gmail.com> <26623.1511927991@sss.pgh.pa.us>
* 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