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 1kJ4Wx-0004ST-6Y for pgsql-general@arkaria.postgresql.org; Fri, 18 Sep 2020 00:45:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJ4Ww-0003IB-0z for pgsql-general@arkaria.postgresql.org; Fri, 18 Sep 2020 00:45:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJ4Wv-0003I4-Q5 for pgsql-general@lists.postgresql.org; Fri, 18 Sep 2020 00:45:37 +0000 Received: from ook.raf.org ([2402:1f00:8100:400::31]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJ4Wt-0007Ye-AS for pgsql-general@lists.postgresql.org; Fri, 18 Sep 2020 00:45:36 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id 9921B5DE1E for ; Fri, 18 Sep 2020 10:45:30 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at ook.raf.org Received: from ook.raf.org ([127.0.0.1]) by localhost (ook.raf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w71r_OOYjwBA for ; Fri, 18 Sep 2020 10:45:29 +1000 (AEST) Received: by ook.raf.org (Postfix, from userid 1001) id DA79A5E26D; Fri, 18 Sep 2020 10:45:29 +1000 (AEST) Date: Fri, 18 Sep 2020 10:45:29 +1000 From: raf To: pgsql-general@lists.postgresql.org Subject: Re: PostgreSQL processes use large amount of private memory on Windows Message-ID: <20200918004529.ejhcosjxthdkenoj@raf.org> References: <146973.1600351567@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <146973.1600351567@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Sep 17, 2020 at 10:06:07AM -0400, Tom Lane wrote: > =?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 For what it's worth, I have 171305 lines of plpgsql/sql functions and it hasn't caused any problem on a server with 4GB RAM. With a small number of long-lived connections. cheers, raf