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 1hboJw-0008Ma-Jr for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2019 15:40:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hboJv-00041W-0d for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2019 15:40:51 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hboJu-00041A-NU for pgsql-hackers@lists.postgresql.org; Fri, 14 Jun 2019 15:40:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hboJs-00031L-D2 for pgsql-hackers@postgresql.org; Fri, 14 Jun 2019 15:40:50 +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 x5EFeahh028935; Fri, 14 Jun 2019 11:40:36 -0400 From: Tom Lane To: Heikki Linnakangas cc: pgsql-hackers Subject: Re: Allow table AM's to cache stuff in relcache In-reply-to: References: Comments: In-reply-to Heikki Linnakangas message dated "Fri, 14 Jun 2019 18:20:29 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28933.1560526836.1@sss.pgh.pa.us> Date: Fri, 14 Jun 2019 11:40:36 -0400 Message-ID: <28934.1560526836@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Heikki Linnakangas writes: > Index AM's can cache stuff in RelationData->rd_amcache. In the zedstore > table AM we've been hacking on, I'd like to also use rd_amcache to cache > some information, but that's not currently possible, because rd_amcache > can only be used by index AMs, not table AMs. > Attached patch allows rd_amcache to also be used by table AMs. Seems reasonable. > In the patch, I documented that rd_amcache must be allocated in > CacheMemoryContext, or in rd_indexcxt if it's an index. It works, but > it's a bit weird. Given the way the patch is implemented, it doesn't really matter which context it's in, does it? The retail pfree is inessential but also harmless, if rd_amcache is in rd_indexcxt. So we could take out the "must". I think it's slightly preferable to use rd_indexcxt if available, to reduce the amount of loose junk in CacheMemoryContext. > It would nice to have one memory context in every > relcache entry, to hold all the stuff related to it, including > rd_amcache. In other words, it would be nice if we had "rd_indexcxt" for > tables, too, not just indexes. That would allow tracking memory usage > more accurately, if you're debugging an out of memory situation for example. We had some discussion related to that in the "hyrax vs. RelationBuildPartitionDesc" thread. I'm not quite sure where we'll settle on that, but some redesign seems inevitable. regards, tom lane