Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWTa5-0000zS-P2 for pgsql-general@arkaria.postgresql.org; Mon, 10 Dec 2018 21:59:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gWTa4-0005fK-F0 for pgsql-general@arkaria.postgresql.org; Mon, 10 Dec 2018 21:59:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWTa4-0005fD-3A for pgsql-general@lists.postgresql.org; Mon, 10 Dec 2018 21:59:12 +0000 Received: from sonic312-21.consmr.mail.bf2.yahoo.com ([74.6.128.83]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWTa0-0004yI-V1 for pgsql-general@postgresql.org; Mon, 10 Dec 2018 21:59:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1544479147; bh=bktgxPDHyvxw+KdS/PaOUD+S3Xm/HYGfuRpM+8KTSLo=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject; b=QKZuBMk8jwr/tfXgCFbYMPDOFFhmrA5szP1J2rKTsKSIkrPujKgj88YFINv7FePdltfQZrie7sFkTW7FchdsVdfKKyWfY/pvoHXfl109fPSm3vCSCJH0ELmekxjzuMPJs8hCTt1a4TxsONlVASnYqYzNaZPxTVsQCMQa1datAVBk4WkVUX41Ke8S5FbCAT8niUBS2XYwDgD0xPhRGpmQMOfJZudTqLhMGDTJSfxq/eg4YVT0//W6vO2s8b6wOFIwGOBDabrtiA4kEmvHURWrNTOYGiSbhX/Pz2F7Z3TIiVgTN4dIhR62s9JQ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.NlBlGDDniIXdPs_S5NnP 50Hg.jXhd5drCoIGZYFbsFA-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.bf2.yahoo.com with HTTP; Mon, 10 Dec 2018 21:59:07 +0000 Date: Mon, 10 Dec 2018 21:57:29 +0000 (UTC) From: Thomas Carroll To: Tom Lane Cc: "pgsql-general@postgresql.org" Message-ID: <1497611735.1978595.1544479049695@mail.yahoo.com> 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> Subject: Re: Memory exhaustion due to temporary tables? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1978594_553499622.1544479049694" X-Mailer: WebService/1.1.12857 YMailNorrin Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0 Content-Length: 4993 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_1978594_553499622.1544479049694 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Monday, December 10, 2018, 3:45:33 PM EST, Tom Lane wrote: =20 =20 Thomas Carroll writes: > Postgres version: 10.5.=C2=A0 work_mem setting: 4MB, shared_buffers setti= ng: 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. =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 regards, tom lane On Monday, December 10, 2018, 3:45:33 PM EST, Tom Lane = wrote:=20 > I imagine you checked this already, but ... what is temp_buffers set to? Thanks for your reply!=C2=A0 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 t= able are discarded from the previous invocation, so there is no need to do = any vacuuming. Thanks again,Tom =20 ------=_Part_1978594_553499622.1544479049694 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
=20
On Monday, December 10, 2018, 3:45:33 PM EST, Tom Lane = <tgl@sss.pgh.pa.us> wrote:


Thomas Carroll <t= omfecarroll@yahoo.com> writes:

> Postgres version: 10= .5.  work_mem setting: 4MB, shared_buffers setting: 800 MB, connection= s typically around 30-40.


I imag= ine you checked this already, but ... what is temp_buffers set to?
That constrains the maximum memory used for temporary-table buffe= rs in
each process, and an unreasonable setting for it co= uld lead to the
described behavior.
Another thing to keep in mind with long-lived "temporary" t= ables 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 wil= l bloat, which could contribute to excessive
use of tempo= rary-table buffers.

  &= nbsp;         regards, tom lane
On Monday, December 10, 2018, 3:45:33 PM EST, Tom Lane &l= t;tgl@sss.pgh.pa.us> wrote:

> I ima= gine you checked this already, but ... what is temp_buffers set to?<= /span>

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

> Another thing to keep in mind with l= ong-lived "temporary" tables...

WRT tem= p 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...

<= /div>
So my perhaps-wrong expectation is that all remnants of the old t= emporary table are discarded from the previous invocation, so there is no n= eed to do any vacuuming.

Thanks again,
T= om




------=_Part_1978594_553499622.1544479049694--