Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 7DA1B98FC83 for ; Tue, 8 May 2012 04:22:56 -0300 (ADT) Received: from exprod7og111.obsmtp.com ([64.18.2.175]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SRel3-0000uN-ME for pgsql-bugs@postgresql.org; Tue, 08 May 2012 07:22:55 +0000 Received: from mail-lb0-f179.google.com ([209.85.217.179]) (using TLSv1) by exprod7ob111.postini.com ([64.18.6.12]) with SMTP ID DSNKT6jJwHA0jhz2AYNVQHI6yneH0qNC6zUi@postini.com; Tue, 08 May 2012 00:22:53 PDT Received: by lban1 with SMTP id n1so3818009lba.24 for ; Tue, 08 May 2012 00:22:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=oBxkcSQLkY7+30gxToNMMmrvJzfDcMOI84zW+OKNFJw=; b=XYA3EZ1ApLctRz66lFiYgn/cNbvd6aB6D8xP7+2MHifqGEx6pAO3lsZFGogwLCLyit /IqQnYLGEfDBvR5atj2tY4cfL92Mft4cj16L6bB/w7uJjBokKFZSz+7enYTPU4lfvgPB ziBhqS8ADk2DcGMWfLXDbBa3E/okQD9yEDBn6wffrJlQ2Y8T1TDLQcEY0e0TBt3Zexg3 F9sFoptu4cSP0qUZeQ5XPsAFfgFGS76uG9sK9e1ad2vp+FX7wNpX5TfQS705DhN5Ele6 dC9O3ozXiTWBh+TKROo1ZQW9rWbZi+tDa6AUM8bkOiwe+tKTGga3S9P0oxeWhEskU5u0 yrzQ== Received: by 10.112.40.102 with SMTP id w6mr8172697lbk.59.1336461758622; Tue, 08 May 2012 00:22:38 -0700 (PDT) Received: from [192.168.1.102] (dsl-hkibrasgw2-ff6cc300-200.dhcp.inet.fi. [88.195.108.200]) by mx.google.com with ESMTPS id h9sm26512967lbi.9.2012.05.08.00.22.36 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 May 2012 00:22:37 -0700 (PDT) Message-ID: <4FA8C9BB.2050703@enterprisedb.com> Date: Tue, 08 May 2012 10:22:35 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.3) Gecko/20120329 Icedove/10.0.3 MIME-Version: 1.0 To: Tom Lane CC: tom@tomforb.es, pgsql-bugs@postgresql.org Subject: Re: BUG #6629: Creating a gist index fails with "too many LWLocks taken" References: <4FA7EC37.5070703@enterprisedb.com> <27017.1336405902@sss.pgh.pa.us> In-Reply-To: <27017.1336405902@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQkZxTFMS9zzDowGY2truGxO86A0Zwuf1jsV4XDL0qyog4RDQYDna/Xj4mfEtys3eMoTap4h X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201205/44 X-Sequence-Number: 33015 On 07.05.2012 18:51, Tom Lane wrote: > Heikki Linnakangas writes: >> I wrote a quick patch to do that, and with the patch the index build >> finished - but it took hours. And the index was 10GB in size, where the >> heap is just 12 MB, and searches using the index take ages. > > Hm, is the example exploiting some pessimal behavior in the picksplit > logic for the particular opclass? Maybe that's something to fix, too. Yep. I added an elog() to picksplit to print how many tuples went to left and right pages. This seems to be the same behavior described here: http://archives.postgresql.org/pgsql-performance/2009-04/msg00320.php, where one entry goes to one page, and all the rest to the other page. We changed the picksplit algorithm for 'seg' to fix that. I'm not too familiar with these datatypes, I'm not sure if we could do the same for intarray. Tom F's original test case used arrays of 50 integers, but you can see the same with much smaller arrays, too. Here's a snippet of the output with arrays of five integers: LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 9 LOG: --------picksplit 9 - 1 LOG: --------picksplit 1 - 9 LOG: --------picksplit 60 - 63 LOG: --------picksplit 1 - 9 LOG: --------picksplit 9 - 1 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 9 LOG: --------picksplit 9 - 1 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 10 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 10 LOG: --------picksplit 9 - 1 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 10 LOG: --------picksplit 10 - 1 LOG: --------picksplit 1 - 10 LOG: --------picksplit 9 - 1 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 9 LOG: --------picksplit 10 - 1 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 9 LOG: --------picksplit 9 - 1 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 9 LOG: --------picksplit 9 - 1 LOG: --------picksplit 1 - 9 LOG: --------picksplit 1 - 9 LOG: --------picksplit 9 - 1 LOG: --------picksplit 1 - 9 LOG: --------picksplit 61 - 62 LOG: --------picksplit 9 - 1 ... -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com