Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCS2p-000178-7a for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Jun 2016 13:36:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bCS2o-0007EH-HM for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Jun 2016 13:36:46 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bCS2m-0007E4-U1 for pgsql-bugs@postgresql.org; Mon, 13 Jun 2016 13:36:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bCS2k-0001cP-0K for pgsql-bugs@postgresql.org; Mon, 13 Jun 2016 13:36:43 +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 u5DDaW8x004401; Mon, 13 Jun 2016 09:36:32 -0400 From: Tom Lane To: depesz@depesz.com cc: Jeff Janes , Pg Bugs Subject: Re: PostgreSQL (9.3 and 9.6) eats all memory when using many tables In-reply-to: <20160613093907.GA10381@depesz.com> References: <20160609154610.GA20600@depesz.com> <20160613093907.GA10381@depesz.com> Comments: In-reply-to hubert depesz lubaczewski message dated "Mon, 13 Jun 2016 11:39:07 +0200" Date: Mon, 13 Jun 2016 09:36:32 -0400 Message-ID: <4400.1465824992@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org hubert depesz lubaczewski writes: > While I do appreciate caching of metadata, it is causing serious > problems, which we will alleviate with server_lifetime, but I would much > prefer a setting like: > internal_cache_limit = 256MB Be careful what you ask for, you might get it. There used to be exactly such a limit in the catcache logic, which we ripped out because it caused far more performance problems than it fixed. See https://www.postgresql.org/message-id/flat/5141.1150327541%40sss.pgh.pa.us While we have no direct experience with limiting the plancache size, I'd expect a pretty similar issue there: a limit will either do nothing except impose substantial bookkeeping overhead (if it's more than the number of plans in your working set) or it will result in a performance disaster from cache thrashing (if it's less). You can only avoid falling off the performance cliff if your workload has *very* strong locality of reference, and that tends not to be the case. Another problem, if the bloat is being driven by explicit PREPARE commands as you illustrate here, is that the backend doesn't get to silently discard prepared statements. We could reduce the amount of memory per prepared statement by dropping the plan tree, but we'd still have to keep the parse tree, so there's still bloat. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs