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 1gkbCo-0005F9-6l for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Jan 2019 20:57: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 1gkbCm-0005od-Ke for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Jan 2019 20:57:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gkbCm-0005oW-AX for pgsql-hackers@lists.postgresql.org; Fri, 18 Jan 2019 20:57:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gkbCj-0007Zn-Sz for pgsql-hackers@lists.postgresql.org; Fri, 18 Jan 2019 20:57:31 +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 x0IKvHDI001392; Fri, 18 Jan 2019 15:57:18 -0500 From: Tom Lane To: Robert Haas cc: Bruce Momjian , Kyotaro HORIGUCHI , "Ideriha, Takeshi" , "pgsql-hackers@lists.postgresql.org" , "Tsunakawa, Takayuki" , "alvherre@alvh.no-ip.org" , "andres@anarazel.de" , "michael.paquier@gmail.com" , "david@pgmasters.net" , "craig@2ndquadrant.com" Subject: Re: Protect syscache from bloating with negative cache entries In-reply-to: References: <4E72940DA2BF16479384A86D54D0988A6F1BCB6F@G01JPEXMBKW04> <20181019.173457.68080786.horiguchi.kyotaro@lab.ntt.co.jp> <4E72940DA2BF16479384A86D54D0988A6F1F4165@G01JPEXMBKW04> <20181127.193622.252197705.horiguchi.kyotaro@lab.ntt.co.jp> <4E72940DA2BF16479384A86D54D0988A6F3D09C1@G01JPEXMBKW04> <4E72940DA2BF16479384A86D54D0988A6F3D0D5F@G01JPEXMBKW04> <7925.1547397565@sss.pgh.pa.us> <20190117194851.GG10895@momjian.us> Comments: In-reply-to Robert Haas message dated "Fri, 18 Jan 2019 15:50:21 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1390.1547845037.1@sss.pgh.pa.us> Date: Fri, 18 Jan 2019 15:57:17 -0500 Message-ID: <1391.1547845037@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > On Thu, Jan 17, 2019 at 2:48 PM Bruce Momjian wrote: >> Unfortunately, because we have not found something we are happy with, we >> have done nothing. I agree LRU can be expensive. What if we do some >> kind of clock sweep and expiration like we do for shared buffers? I >> think the trick is figuring how frequently to do the sweep. What if we >> mark entries as unused every 10 queries, mark them as used on first use, >> and delete cache entries that have not be used in the past 10 queries. > I still think wall-clock time is a perfectly reasonable heuristic. The easy implementations of that involve putting gettimeofday() calls into hot code paths, which would be a Bad Thing. But maybe we could do this only at transaction or statement start, and piggyback on the gettimeofday() calls that already happen at those times. regards, tom lane