From: Thomas Carroll <tomfecarroll@yahoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Memory exhaustion due to temporary tables?
Date: Mon, 10 Dec 2018 21:57:29 +0000 (UTC)
Message-ID: <1497611735.1978595.1544479049695@mail.yahoo.com> (raw)
In-Reply-To: <2584.1544474727@sss.pgh.pa.us>
References: <2114009259.1866365.1544469996900.ref@mail.yahoo.com>
<2114009259.1866365.1544469996900@mail.yahoo.com>
<2584.1544474727@sss.pgh.pa.us>
On Monday, December 10, 2018, 3:45:33 PM EST, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Thomas Carroll <tomfecarroll@yahoo.com> writes:
> Postgres version: 10.5. work_mem setting: 4MB, shared_buffers setting: 800 MB, connections typically around 30-40.
I imagine you checked this already, but ... what is temp_buffers set to?
That constrains the maximum memory used for temporary-table buffers in
each process, and an unreasonable setting for it could lead to the
described behavior.
Another thing to keep in mind with long-lived "temporary" tables is
that autovacuum can't do anything with them; so it's incumbent on your
application to periodically VACUUM and/or ANALYZE them as needed.
Otherwise such tables will bloat, which could contribute to excessive
use of temporary-table buffers.
regards, tom lane
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.
> Another thing to keep in mind with long-lived "temporary" tables...
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.
Thanks again,Tom
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: tomfecarroll@yahoo.com, tgl@sss.pgh.pa.us
Subject: Re: Memory exhaustion due to temporary tables?
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>
* 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