pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Carroll <tomfecarroll@yahoo.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Memory exhaustion due to temporary tables?
Date: Mon, 10 Dec 2018 17:50:14 -0500
Message-ID: <7049.1544482214@sss.pgh.pa.us> (raw)
In-Reply-To: <1497611735.1978595.1544479049695@mail.yahoo.com>
References: <2114009259.1866365.1544469996900.ref@mail.yahoo.com>
	<2114009259.1866365.1544469996900@mail.yahoo.com>
	<2584.1544474727@sss.pgh.pa.us>
	<1497611735.1978595.1544479049695@mail.yahoo.com>

Thomas Carroll <tomfecarroll@yahoo.com> writes:
>    On Monday, December 10, 2018, 3:45:33 PM EST, Tom Lane <tgl@sss.pgh.pa.us> wrote:  
>> I imagine you checked this already, but ... what is temp_buffers set to?

> Thanks for your reply!  temp_buffers is the default 8MB, and I should have included that in my first email.

Hm.  Well, the temporary-buffer arena definitely won't grow any larger
than that, so the problem is somewhere else.

> WRT temp tables and autovacuum: I realize I need to add an important detail here: The table is created by the function using:
> CREATE TEMPORARY TABLE table_name ON COMMIT DROP AS SELECT...
> So my perhaps-wrong expectation is that all remnants of the old temporary table are discarded from the previous invocation, so there is no need to do any vacuuming.

I see.  The contents of the temp tables certainly go away at commit,
then, but the system catalog entries describing a temp table are just
as real as those for a regular table.  So if you're creating and
dropping temp tables quickly, there's a potential for bloat in the
system catalogs (particularly pg_attribute), which autovacuum might
or might not keep up with at default settings.  Still, I'd only expect
that to lead to disk space growth not memory consumption.

Is the error message spelling really exactly "Cannot allocate memory"?
Because that string appears nowhere in the Postgres backend sources,
and I don't think it's strerror's canonical phrasing for ENOMEM either.
So I'm wondering just where it's coming from.

Also, as mentioned upthread, it'd be interesting to see if there's
a memory context dump showing up in your server log.  It'd look
something roughly like this:

TopMemoryContext: 67440 total in 5 blocks; 14016 free (27 chunks); 53424 used
  TopTransactionContext: 32768 total in 3 blocks; 14992 free (21 chunks); 17776 used
    Combo CIDs: 8192 total in 1 blocks; 1544 free (0 chunks); 6648 used
  LocalBufferContext: 8397248 total in 8 blocks; 7936 free (0 chunks); 8389312 used
  Local Buffer Lookup Table: 32768 total in 3 blocks; 6368 free (7 chunks); 26400 used
  ... lots more ...
Grand total: 9603680 bytes in 238 blocks; 283976 free (240 chunks); 9319704 used

			regards, tom lane




view thread (10+ messages)  latest in thread

Message-ID: <7049.1544482214@sss.pgh.pa.us>
Permalink:  ../7049.1544482214@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7049.1544482214@sss.pgh.pa.us

 · 

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 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, tomfecarroll@yahoo.com
  Subject: Re: Memory exhaustion due to temporary tables?
  In-Reply-To: <7049.1544482214@sss.pgh.pa.us>
  References: <2114009259.1866365.1544469996900.ref@mail.yahoo.com> <2114009259.1866365.1544469996900@mail.yahoo.com> <2584.1544474727@sss.pgh.pa.us> <1497611735.1978595.1544479049695@mail.yahoo.com> <7049.1544482214@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