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 1gWSQo-0006S1-Ps for pgsql-general@arkaria.postgresql.org; Mon, 10 Dec 2018 20:45:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gWSQm-0005zs-UN for pgsql-general@arkaria.postgresql.org; Mon, 10 Dec 2018 20:45:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWSQm-0005zh-MC for pgsql-general@lists.postgresql.org; Mon, 10 Dec 2018 20:45:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWSQk-00046F-Me for pgsql-general@postgresql.org; Mon, 10 Dec 2018 20:45:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wBAKjRIO002585; Mon, 10 Dec 2018 15:45:27 -0500 From: Tom Lane To: Thomas Carroll cc: "pgsql-general@postgresql.org" Subject: Re: Memory exhaustion due to temporary tables? In-reply-to: <2114009259.1866365.1544469996900@mail.yahoo.com> References: <2114009259.1866365.1544469996900.ref@mail.yahoo.com> <2114009259.1866365.1544469996900@mail.yahoo.com> Comments: In-reply-to Thomas Carroll message dated "Mon, 10 Dec 2018 19:26:36 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2583.1544474727.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 10 Dec 2018 15:45:27 -0500 Message-ID: <2584.1544474727@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Carroll 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