Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRMPK-0001Oc-Si for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Dec 2017 18:14:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRMPK-0004XI-FN for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Dec 2017 18:14:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eRMPK-0004X8-8v for pgsql-hackers@lists.postgresql.org; Tue, 19 Dec 2017 18:14:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eRMPH-0002ud-3v for pgsql-hackers@postgresql.org; Tue, 19 Dec 2017 18:14:25 +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 vBJIE9ol000749; Tue, 19 Dec 2017 13:14:09 -0500 From: Tom Lane To: Robert Haas cc: Kyotaro HORIGUCHI , Andres Freund , Michael Paquier , David Steele , Jim Nasby , Craig Ringer , "pgsql-hackers@postgresql.org" Subject: Re: Protect syscache from bloating with negative cache entries In-reply-to: References: <20171218164653.qg7sm6xtn7zfx2hi@alap3.anarazel.de> <20171219.173138.46350691.horiguchi.kyotaro@lab.ntt.co.jp> Comments: In-reply-to Robert Haas message dated "Tue, 19 Dec 2017 11:09:44 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <747.1513707249.1@sss.pgh.pa.us> Date: Tue, 19 Dec 2017 13:14:09 -0500 Message-ID: <748.1513707249@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > On Tue, Dec 19, 2017 at 3:31 AM, Kyotaro HORIGUCHI > wrote: >> I see three kinds of syscache entries. >> >> A. An entry for an actually existing object. >> B. An entry for an object which once existed but no longer. >> C. An entry for a just non-existent objects. > I'm not convinced that it's useful to divide things up this way. Actually, I don't believe that case B exists at all; such an entry should get blown away by syscache invalidation when we commit the DROP command. If one were to stick around, we'd risk false positive lookups later. > I guess I still don't see why B is different. If somebody sits there > and runs queries against non-existent table names at top speed, maybe > they'll query the same non-existent table entries more than once, in > which case keeping the negative entries for the non-existent table > names around until they stop doing it may improve performance. FWIW, my recollection is that the reason for negative cache entries is that there are some very common patterns where we probe for object names (not just table names, either) that aren't there, typically as a side effect of walking through the search_path looking for a match to an unqualified object name. Those cache entries aren't going to get any less useful than the positive entry for the ultimately-found object. So from a lifespan point of view I'm not very sure that it's worth distinguishing cases A and C. It's conceivable that we could rewrite all the lookup algorithms so that they didn't require negative cache entries to have good performance ... but I doubt that that's easy to do. regards, tom lane