Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 111E2B5DC1D for ; Thu, 14 Jul 2011 05:44:54 -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 86497-07 for ; Thu, 14 Jul 2011 08:43:10 +0000 (UTC) Received: from mx1.hub.org (mx1.hub.org [200.46.208.106]) by mail.postgresql.org (Postfix) with ESMTP id F2733B5DC60 for ; Thu, 14 Jul 2011 05:42:14 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og124.obsmtp.com (exprod7og124.obsmtp.com [64.18.2.26]) by mx1.hub.org (Postfix) with ESMTP id C4BCE27FB6F4 for ; Thu, 14 Jul 2011 05:42:11 -0300 (ADT) Received: from mail-fx0-f48.google.com ([209.85.161.48]) (using TLSv1) by exprod7ob124.postini.com ([64.18.6.12]) with SMTP ID DSNKTh6r4U9dvho78BI35PsUSiJQ9vzQkPYh@postini.com; Thu, 14 Jul 2011 01:42:12 PDT Received: by mail-fx0-f48.google.com with SMTP id 7so506659fxg.21 for ; Thu, 14 Jul 2011 01:42:09 -0700 (PDT) Received: by 10.223.145.6 with SMTP id b6mr3212544fav.2.1310632929769; Thu, 14 Jul 2011 01:42:09 -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 r12sm16995fam.0.2011.07.14.01.42.07 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Jul 2011 01:42:08 -0700 (PDT) Message-ID: <4E1EABD9.5000308@enterprisedb.com> Date: Thu, 14 Jul 2011 11:42:01 +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: <4DFA4AE5.1010806@enterprisedb.com> <4E044D68.5070605@enterprisedb.com> <4E0894FF.8080202@enterprisedb.com> <26338.1310134685@sss.pgh.pa.us> <4E1DA4CB.9020209@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.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, NO_DNS_FOR_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201107/717 X-Sequence-Number: 191816 On 14.07.2011 11:33, Alexander Korotkov wrote: > On Wed, Jul 13, 2011 at 5:59 PM, Heikki Linnakangas< > heikki.linnakangas@enterprisedb.com> wrote: > >> One thing that caught my eye is that when you empty a buffer, you load the >> entire subtree below that buffer, down to the next buffered or leaf level, >> into memory. Every page in that subtree is kept pinned. That is a problem; >> in the general case, the buffer manager can only hold a modest number of >> pages pinned at a time. Consider that the minimum value for shared_buffers >> is just 16. That's unrealistically low for any real system, but the default >> is only 32MB, which equals to just 4096 buffers. A subtree could easily be >> larger than that. >> > With level step = 1 we need only 2 levels in subtree. With mininun index > tuple size (12 bytes) each page can have at maximum 675. Thus I think > default shared_buffers is enough for level step = 1. Hundreds of buffer pins is still a lot. And with_level_step=2, the number of pins required explodes to 675^2 = 455625. Pinning a buffer that's already in the shared buffer cache is cheap, I doubt you're gaining much by keeping the private hash table in front of the buffer cache. Also, it's possible that not all of the subtree is actually required during the emptying, so in the worst case pre-loading them is counter-productive. > I believe it's enough > to add check we have sufficient shared_buffers, isn't it? Well, what do you do if you deem that shared_buffers is too small? Fall back to the old method? Also, shared_buffers is shared by all backends, so you can't assume that you get to use all of it for the index build. You'd need a wide safety margin. >> I don't think you're benefiting at all from the buffering that BufFile does >> for you, since you're reading/writing a full block at a time anyway. You >> might as well use the file API in fd.c directly, ie. >> OpenTemporaryFile/FileRead/**FileWrite. > > BufFile is distributing temporary data through several files. AFAICS > postgres avoids working with files larger than 1GB. Size of tree buffers can > easily be greater. Without BufFile I need to maintain set of files manually. Ah, I see. Makes sense. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com