Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7ADD7B5DD56 for ; Mon, 5 Sep 2011 13:32:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 44586-04 for ; Mon, 5 Sep 2011 16:32:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og127.obsmtp.com (exprod7og127.obsmtp.com [64.18.2.210]) by mail.postgresql.org (Postfix) with ESMTP id 4870DB5DC3E for ; Mon, 5 Sep 2011 13:30:17 -0300 (ADT) Received: from mail-fx0-f54.google.com ([209.85.161.54]) (using TLSv1) by exprod7ob127.postini.com ([64.18.6.12]) with SMTP ID DSNKTmT5GLQuzbFn4kpD8mLQS4+g6vuFtfbw@postini.com; Mon, 05 Sep 2011 09:30:17 PDT Received: by fxe4 with SMTP id 4so4719824fxe.41 for ; Mon, 05 Sep 2011 09:30:15 -0700 (PDT) Received: by 10.223.56.15 with SMTP id w15mr20710fag.139.1315240214707; Mon, 05 Sep 2011 09:30:14 -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 m8sm4168278fae.17.2011.09.05.09.30.10 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Sep 2011 09:30:11 -0700 (PDT) Message-ID: <4E64F911.8010007@enterprisedb.com> Date: Mon, 05 Sep 2011 19:30:09 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.21) Gecko/20110831 Icedove/3.1.13 MIME-Version: 1.0 CC: Alexander Korotkov , Robert Haas , pgsql-hackers Subject: Re: WIP: Fast GiST index build References: <4E4AAC49.7070401@enterprisedb.com> <4E4AC0B9.8070203@enterprisedb.com> <4E4AC1C3.4070003@enterprisedb.com> <4E569D9A.4020308@enterprisedb.com> <4E5CA88C.50008@enterprisedb.com> <4E5F495F.2010303@enterprisedb.com> <4E64AE3E.9000901@enterprisedb.com> In-Reply-To: <4E64AE3E.9000901@enterprisedb.com> 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=-0.879 tagged_above=-5 required=5 tests=BAYES_00=-1.9, MISSING_HEADERS=1.021 X-Spam-Level: X-Archive-Number: 201109/164 X-Sequence-Number: 194353 On 05.09.2011 14:10, Heikki Linnakangas wrote: > On 01.09.2011 12:23, Alexander Korotkov wrote: >> On Thu, Sep 1, 2011 at 12:59 PM, Heikki Linnakangas< >> heikki.linnakangas@enterprisedb.com> wrote: >> >>> So I changed the test script to generate the table as: >>> >>> CREATE TABLE points AS SELECT random() as x, random() as y FROM >>> generate_series(1, $NROWS); >>> >>> The unordered results are in: >>> >>> testname | nrows | duration | accesses >>> -----------------------------+**-----------+-----------------+**---------- >>> >>> points unordered buffered | 250000000 | 05:56:58.575789 | 2241050 >>> points unordered auto | 250000000 | 05:34:12.187479 | 2246420 >>> points unordered unbuffered | 250000000 | 04:38:48.663952 | 2244228 >>> >>> Although the buffered build doesn't lose as badly as it did with more >>> overlap, it still doesn't look good :-(. Any ideas? >> >> But it's still a lot of overlap. It's about 220 accesses per small area >> request. It's about 10 - 20 times greater than should be without >> overlaps. >> If we roughly assume that 10 times more overlap makes 1/10 of tree to be >> used for actual inserts, then that part of tree can easily fit to the >> cache. >> You can try my splitting algorithm on your test setup (it this case I >> advice >> to start from smaller number of rows, 100 M for example). >> I'm requesting real-life datasets which makes troubles in real life from >> Oleg. Probably those datasets is even larger or new linear split produce >> less overlaps on them. > > I made a small tweak to the patch, and got much better results (this is > with my original method of generating the data): > > testname | nrows | duration | accesses > -----------------------------+-----------+-----------------+---------- > points unordered buffered | 250000000 | 03:34:23.488275 | 3945486 > points unordered auto | 250000000 | 02:55:10.248722 | 3767548 > points unordered unbuffered | 250000000 | 04:02:04.168138 | 4564986 The full results of this test are in: testname | nrows | duration | accesses -----------------------------+-----------+-----------------+---------- points unordered buffered | 250000000 | 03:34:23.488275 | 3945486 points unordered auto | 250000000 | 02:55:10.248722 | 3767548 points unordered unbuffered | 250000000 | 04:02:04.168138 | 4564986 points ordered buffered | 250000000 | 02:00:10.467914 | 5572906 points ordered auto | 250000000 | 02:16:01.859039 | 5435673 points ordered unbuffered | 250000000 | 03:23:18.061742 | 1875826 (6 rows) Interestingly, in this test case the buffered build was significantly faster even in the case of ordered input - but the quality of the produced index was much worse. I suspect it's because of the last-in-first-out nature of the buffering, tuples that pushed into buffers first are flushed to lower levels last. Tweaking the data structures to make the buffer flushing a FIFO process might help with that, but I'm afraid that might make our cache hit ratio worse when reading pages from the temporary file. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com