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 1gG2yD-0008Tu-5t for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Oct 2018 14:20:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gG2yB-0008DY-9V for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Oct 2018 14:20:11 +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.89) (envelope-from ) id 1gG2yB-0008DN-2D; Fri, 26 Oct 2018 14:20:11 +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 1gG2y8-0005vC-HF; Fri, 26 Oct 2018 14:20:10 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w9QEK3Mm011007; Fri, 26 Oct 2018 10:20:03 -0400 From: Tom Lane To: Alvaro Herrera cc: Amit Langote , Bruno Wolff III , pgsql-general@lists.postgresql.org, pgsql-hackers@lists.postgresql.org Subject: Re: Should pg 11 use a lot more memory building an spgist index? In-reply-to: <20181026140927.oh4gd367st47li6h@alvherre.pgsql> References: <20181026140927.oh4gd367st47li6h@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Fri, 26 Oct 2018 11:09:27 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26003.1540563602.1@sss.pgh.pa.us> Date: Fri, 26 Oct 2018 15:20:02 +0100 Message-ID: <26004.1540563602@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2018-Oct-26, Tom Lane wrote: >> After a quick look around, I think that making systable_begin/endscan >> do this is a nonstarter; there are just too many call sites that would >> be affected. Now, you could imagine specifying that indexes on system >> catalogs (in practice, only btree) have to clean up at endscan time >> but other index types don't, so that only operations that might be >> scanning user indexes need to have suitable wrapping contexts. Not sure >> there's a lot of benefit to that, though. > How about modifying SysScanDescData to have a memory context member, > which is created by systable_beginscan and destroyed by endscan? I think it would still have problems, in that it would affect in which context index_getnext delivers its output. We could reasonably make these sorts of changes in places where the entire index_beginscan/ index_getnext/index_endscan call structure is in one place, but that doesn't apply for the systable functions. Also, going in that direction would imply an additional memory context switch / switch-back per tuple processed (around the index_getnext call), which would create questions about whether it has a negative performance impact. regards, tom lane