Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1etmvG-0008Lp-5w for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Mar 2018 04:12:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1etmvE-00021z-Uv for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Mar 2018 04:12:52 +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.89) (envelope-from ) id 1etmvE-00021p-K4 for pgsql-hackers@lists.postgresql.org; Thu, 08 Mar 2018 04:12:52 +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.89) (envelope-from ) id 1etmvB-0002Ov-NP for pgsql-hackers@postgresql.org; Thu, 08 Mar 2018 04:12:51 +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 w284CT63000353; Wed, 7 Mar 2018 23:12:30 -0500 From: Tom Lane To: Kyotaro HORIGUCHI cc: tsunakawa.takay@jp.fujitsu.com, alvherre@alvh.no-ip.org, andres@anarazel.de, robertmhaas@gmail.com, michael.paquier@gmail.com, david@pgmasters.net, Jim.Nasby@bluetreble.com, craig@2ndquadrant.com, pgsql-hackers@postgresql.org Subject: Re: Protect syscache from bloating with negative cache entries In-reply-to: <20180308.124748.178336202.horiguchi.kyotaro@lab.ntt.co.jp> References: <20180307.172545.231972323.horiguchi.kyotaro@lab.ntt.co.jp> <20180307110138.qp3wsav7ka43qrlj@alvherre.pgsql> <0A3221C70F24FB45833433255569204D1F8FF0D9@G01JPEXMBYT05> <20180308.124748.178336202.horiguchi.kyotaro@lab.ntt.co.jp> Comments: In-reply-to Kyotaro HORIGUCHI message dated "Thu, 08 Mar 2018 12:47:48 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <351.1520482349.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 07 Mar 2018 23:12:29 -0500 Message-ID: <352.1520482349@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Kyotaro HORIGUCHI writes: > At Thu, 8 Mar 2018 00:28:04 +0000, "Tsunakawa, Takayuki" wrote in <0A3221C70F24FB45833433255569204D1F8FF0D9@G01JP= EXMBYT05> >> Yes. We are now facing the problem of too much memory use by PostgreSQ= L, where about some applications randomly access about 200,000 tables. It= is estimated based on a small experiment that each backend will use sever= al to ten GBs of local memory for CacheMemoryContext. The total memory us= e will become over 1 TB when the expected maximum connections are used. >> = >> I haven't looked at this patch, but does it evict all kinds of entries = in CacheMemoryContext, ie. relcache, plancache, etc? > This works only for syscaches, which could bloat with entries for > nonexistent objects. > Plan cache is a utterly deferent thing. It is abandoned at the > end of a transaction or such like. When I was at Salesforce, we had *substantial* problems with plancache bloat. The driving factor there was plans associated with plpgsql functions, which Salesforce had a huge number of. In an environment like that, there would be substantial value in being able to prune both the plancache and plpgsql's function cache. (Note that neither of those things are "abandoned at the end of a transaction".) > Relcache is not based on catcache and out of the scope of this > patch since it doesn't get bloat with nonexistent entries. It > uses dynahash and we could introduce a similar feature to it if > we are willing to cap relcache size. I think if the case of concern is an application with 200,000 tables, it's just nonsense to claim that relcache size isn't an issue. In short, it's not really apparent to me that negative syscache entries are the major problem of this kind. I'm afraid that you're drawing very large conclusions from a specific workload. Maybe we could fix that workload some other way. regards, tom lane