Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIuYH-00008e-67 for pgsql-general@arkaria.postgresql.org; Thu, 17 Sep 2020 14:06:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kIuYE-0004Ho-Tm for pgsql-general@arkaria.postgresql.org; Thu, 17 Sep 2020 14:06:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIuYE-0004F1-L1 for pgsql-general@lists.postgresql.org; Thu, 17 Sep 2020 14:06:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kIuY7-0003XN-Jv for pgsql-general@lists.postgresql.org; Thu, 17 Sep 2020 14:06:18 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 08HE678l146974; Thu, 17 Sep 2020 10:06:07 -0400 From: Tom Lane To: =?UTF-8?Q?=C3=98ystein_Kolsrud?= cc: pgsql-general@lists.postgresql.org Subject: Re: PostgreSQL processes use large amount of private memory on Windows In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?=C3=98ystein_Kolsrud?= message dated "Thu, 17 Sep 2020 11:19:07 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <146972.1600351567.1@sss.pgh.pa.us> Date: Thu, 17 Sep 2020 10:06:07 -0400 Message-ID: <146973.1600351567@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?UTF-8?Q?=C3=98ystein_Kolsrud?= writes: > So my question is: When does a postgres process forked for a connection use > private memory instead of shared, and what can I do to avoid this? The only significant long-term consumption of private memory is for caches. There are catalog caches, which can get large if the session accesses a whole lot of database objects (e.g., thousands of different tables). Some of the PLs maintain caches with parsed versions of any function that's been executed. (An ex-employer of mine had a lot of trouble in that regard, because they had hundreds of thousands of lines worth of plpgsql functions.) There isn't any user-accessible knob for limiting the size of those caches. If you have a problem of that sort, about the only way to mitigate it is to use fewer backends so that the total memory consumption stays in bounds, or redesign your application. In some cases it might help to restart your sessions when they get too big, but that seems like at best a band-aid. regards, tom lane