Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 65E58B5DBDA for ; Wed, 10 Aug 2011 16:45:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 08948-07 for ; Wed, 10 Aug 2011 19:45:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og109.obsmtp.com (exprod7og109.obsmtp.com [64.18.2.171]) by mail.postgresql.org (Postfix) with ESMTP id 32B66B5DC06 for ; Wed, 10 Aug 2011 16:45:24 -0300 (ADT) Received: from mail-fx0-f49.google.com ([209.85.161.49]) (using TLSv1) by exprod7ob109.postini.com ([64.18.6.12]) with SMTP ID DSNKTkLf08aGNJaN9cKXcwFVDcC9iqtn/V/8@postini.com; Wed, 10 Aug 2011 12:45:24 PDT Received: by fxd20 with SMTP id 20so1774715fxd.22 for ; Wed, 10 Aug 2011 12:45:22 -0700 (PDT) Received: by 10.223.1.201 with SMTP id 9mr7443102fag.91.1313005522202; Wed, 10 Aug 2011 12:45:22 -0700 (PDT) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id d1sm974660fai.4.2011.08.10.12.45.20 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Aug 2011 12:45:20 -0700 (PDT) Message-ID: <4E42DFCE.3050904@enterprisedb.com> Date: Wed, 10 Aug 2011 22:45:18 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.18) Gecko/20110626 Icedove/3.1.11 MIME-Version: 1.0 To: Alexander Korotkov CC: pgsql-hackers Subject: Re: WIP: Fast GiST index build References: <4E2DBB60.80604@enterprisedb.com> <4E2EF83A.8000304@enterprisedb.com> <4E31D03D.70206@enterprisedb.com> <4E3977D8.1020506@enterprisedb.com> <4E3FAB1D.1060105@enterprisedb.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201108/499 X-Sequence-Number: 193254 On 10.08.2011 13:19, Alexander Korotkov wrote: > Hi! > > Here is last verion of the patch. > List of changes: > 1) Neighbor relocation and prefetch were removed. They will be supplied as > separate patches. unloadNodeBuffers() is now dead code. > 2) Final emptying now using standart lists of all buffers by levels. > 3) Automatic switching again use simple comparison of index size and > effective_cache_size. LEAF_PAGES_STATS_* are unused now. Should avoid calling smgrnblocks() on every tuple, the overhead of that could add up. > 4) Some renames. In particular GISTLoadedPartItem > to GISTBufferingInsertStack. > 5) Some comments were corrected and some were added. > 6) pgindent > 7) rebased with head > > Readme update and user documentation coming soon. I wonder, how hard would it be to merge gistBufferingBuildPlaceToPage() with the gistplacetopage() function used in the main codepath? There's very little difference between them, and it would be nice to maintain just one function. At the very least I think there should be a comment in both along the lines of "NOTE: if you change this function, make sure you update XXXX (the other function) as well!" In gistbuild(), in the final emptying stage, there's this special-case handling for the root block before looping through the buffers in the buffersOnLevels lists: > for (;;) > { > nodeBuffer = getNodeBuffer(gfbb, &buildstate.giststate, GIST_ROOT_BLKNO, > InvalidOffsetNumber, NULL, false); > if (!nodeBuffer || nodeBuffer->blocksCount <= 0) > break; > MemoryContextSwitchTo(gfbb->context); > gfbb->bufferEmptyingStack = lcons(nodeBuffer, gfbb->bufferEmptyingStack); > MemoryContextSwitchTo(buildstate.tmpCtx); > processEmptyingStack(&buildstate.giststate, &insertstate); > } What's the purpose of that? Wouldn't the loop through buffersOnLevels lists take care of the root node too? The calculations in initBuffering() desperately need comments. As does the rest of the code too, but the heuristics in that function are particularly hard to understand without some explanation. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com