From: Kevin Grittner <kgrittn@ymail.com>
To: jkoceniak@mediamath.com <jkoceniak@mediamath.com>
To: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13672: What is the purpose of the temp_buffers setting?
Date: Mon, 12 Oct 2015 13:37:16 +0000 (UTC)
Message-ID: <1111603541.2485705.1444657036683.JavaMail.yahoo@mail.yahoo.com> (raw)
In-Reply-To: <20151009234654.328.91105@wrigleys.postgresql.org>
References: <20151009234654.328.91105@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Friday, October 9, 2015 11:34 PM, "jkoceniak@mediamath.com"
<jkoceniak@mediamath.com> wrote:
> I set temp_buffers to a high value (8GB). My understanding was
> that temporary tables stay in memory if they do not go over
> temp_buffers limit.
Since temp_buffers is a limit on how much process-local memory each
connection can reserve for temporary table buffers, 8GB seems like
an insanely high value. Keep in mind that once a connection
allocates memory for this purpose, it doesn't release it until the
connection is closed, so with this setting, if you had 100
connections open which had all used temporary tables, you might
have 800GB set aside for this purpose even if all of the
connections were idle and had dropped all of their temporary
tables.
> However, I noticed that any temporary tables that I create are
> written to disk. (i.e. I see t181_869525834 filenames in the data
> directory)
Are you sure that those temporary files are related to temporary
tables? temp_buffers is only for pages in temporary tables, not
for the temporary work files created by sorts, hash joins, CTEs,
etc. Those spill to disk if work_mem is not adequate to hold them.
> Also, I don't see any query performance improvements when
> querying temporary tables using a higher temp_buffers value.
Keep in mind that even if a temporary table doesn't fit into
temp_buffers, the OS cache will tend to cache it for some period of
time, so you are likely only dealing with difference between
accessing the pages in process-local memory versus bringing them in
from the OS RAM cache. That might be hard to measure.
> What is the purpose of this setting and what performance
> improvements would you expect to see by adjusting the
> temp_buffers value?
Personally, I would tend to think that the cases in which
increasing this setting would show any improvement would be few and
far between. I think that the default setting is probably too
high, especially for anyone who increases max_connections from the
default of 100. The setting you have, combined with
max_connections of 1000 could tie up 8TB in this type of cache, for
very dubious benefit.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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-bugs@postgresql.org
Cc: kgrittn@ymail.com, jkoceniak@mediamath.com
Subject: Re: BUG #13672: What is the purpose of the temp_buffers setting?
In-Reply-To: <1111603541.2485705.1444657036683.JavaMail.yahoo@mail.yahoo.com>
References: <20151009234654.328.91105@wrigleys.postgresql.org> <1111603541.2485705.1444657036683.JavaMail.yahoo@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