Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1C5F3B5DC07 for ; Tue, 30 Aug 2011 06:08:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 26695-04 for ; Tue, 30 Aug 2011 09:08:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og123.obsmtp.com (exprod7og123.obsmtp.com [64.18.2.24]) by mail.postgresql.org (Postfix) with ESMTP id 9E415B5DBFB for ; Tue, 30 Aug 2011 06:08:33 -0300 (ADT) Received: from mail-ew0-f46.google.com ([209.85.215.46]) (using TLSv1) by exprod7ob123.postini.com ([64.18.6.12]) with SMTP ID DSNKTlyokavm+yL+RyVn85KzFYkLAcU5Ac3L@postini.com; Tue, 30 Aug 2011 02:08:35 PDT Received: by mail-ew0-f46.google.com with SMTP id 4so3219393ewy.5 for ; Tue, 30 Aug 2011 02:08:33 -0700 (PDT) Received: by 10.213.7.80 with SMTP id c16mr1542839ebc.55.1314695312486; Tue, 30 Aug 2011 02:08:32 -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 w51sm3541936eef.45.2011.08.30.02.08.29 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Aug 2011 02:08:30 -0700 (PDT) Message-ID: <4E5CA88C.50008@enterprisedb.com> Date: Tue, 30 Aug 2011 12:08:28 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.20) Gecko/20110820 Icedove/3.1.12 MIME-Version: 1.0 To: Alexander Korotkov CC: Robert Haas , pgsql-hackers Subject: Re: WIP: Fast GiST index build References: <4E3FAB1D.1060105@enterprisedb.com> <4E42DFCE.3050904@enterprisedb.com> <4E4AAC49.7070401@enterprisedb.com> <4E4AC0B9.8070203@enterprisedb.com> <4E4AC1C3.4070003@enterprisedb.com> <4E569D9A.4020308@enterprisedb.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------010307000402090803070608" 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/1320 X-Sequence-Number: 194075 This is a multi-part message in MIME format. --------------010307000402090803070608 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 26.08.2011 17:18, Alexander Korotkov wrote: > On Thu, Aug 25, 2011 at 11:08 PM, Heikki Linnakangas< > heikki.linnakangas@enterprisedb.com> wrote: > >> Could you share the test scripts, patches and data sets etc. needed to >> reproduce the tests you've been running? I'd like to try them out on a test >> server. >> > > 1) I've updated links to the datasets on the wiki page. > 2) Script for index quality testing fastbuild_test.php is in the attachment. > In order to run it you need PHP with pdo and pdo_pgsql modules. Also > plantuner moduler is required (it is used to force planer to use specific > index). After running that script following query returns relative score of > index quality: > > select indexname, avg(count::real/(select count from test_result a2 where > a2.indexname = 'usnoa2_idx3' and a2.predicate = a1.predicate and > a2.tablename = a1.tablename)::real) from test_result a1 where a1.tablename = > 'usnoa2' group by indexname; > > where 'usnoa2' - table name, 'usnoa2_idx3' - name of index which quality was > assumed to be 1. > 3) Patch which makes plantuner work with HEAD is also in attachment. > 4) Patch with my split algorithm implementation is attached. Now it's form > is appropriate only for testing purposes. > 5) For indexes creation I use simple script which is attached as > 'indexes.sql'. Also, similar script with different index names I'm running > with my split patch. > > Feel free to ask questions about all this stuff. Thanks. Meanwhile, I hacked together my own set of test scripts, and let them run over the weekend. I'm still running tests with ordered data, but here are some preliminary results: testname | nrows | duration | accesses -----------------------------+-----------+-----------------+---------- points unordered auto | 250000000 | 08:08:39.174956 | 3757848 points unordered buffered | 250000000 | 09:29:16.47012 | 4049832 points unordered unbuffered | 250000000 | 03:48:10.999861 | 4564986 As you can see, the results are very disappointing :-(. The buffered builds take a lot *longer* than unbuffered ones. I was expecting the buffering to be very helpful at least in these unordered tests. On the positive side, the buffering made index quality somewhat better (accesses column, smaller is better), but that's not what we're aiming at. What's going on here? This data set was large enough to not fit in RAM, the table was about 8.5 GB in size (and I think the index is even larger than that), and the box has 4GB of RAM. Does the buffering only help with even larger indexes that exceed the cache size even more? Test methodology ---------------- These tests consist of creating a gist index using the point datatype. Table "public.points" Column | Type | Modifiers --------+---------+----------- x | integer | y | integer | CREATE INDEX testindex ON points_ordered USING gist (point(x,y)) WITH (buffering = 'on'); The points in the table are uniformly distributed. In the 'unordered' tests, they are in random order. The ordered tests use the exact same data, but sorted by x, y coordinates. The 'accesses' column measures the quality of the produced index. Smaller is better. It is calculated by performing a million queries on the table, selecting points within a small square at evenly spaced locations. Like: (SELECT COUNT(*) FROM points WHERE point(x,y) <@ box(point(xx-20, yy-20), point(xx+20, yy+20))); The number of index pages touched by those queries are count from pg_statio_user_indexes, and that number is reported in the 'accesses' column. I've attached the whole script used. Pass the number of rows to use in the test as argument, and the script does the rest. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com --------------010307000402090803070608 Content-Type: application/x-sh; name="rungisttests.sh" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rungisttests.sh" #!/bin/bash NROWS=$1 echo "BEGIN;" echo "DROP TABLE IF EXISTS points, points_ordered;" echo "CREATE TABLE points (x int4, y int4);" cat > /tmp/creategistdata.c < #include int main(int argc, char **argv) { int nrows; int i; if (argc != 2) exit(1); nrows = atoi(argv[1]); for (i = 0; i < nrows; i++) printf("%d\t%d\n", random() % 100000, random() % 100000); } EOF gcc /tmp/creategistdata.c -o /tmp/creategistdata echo "COPY points FROM stdin;" /tmp/creategistdata $NROWS echo "\." echo "CREATE TABLE points_ordered AS SELECT * FROM points ORDER BY x, y;"; echo "COMMIT;" echo "CREATE TABLE results (testname text, nrows int4, begintime timestamp, endtime timestamp, blks_accessed int4, totalrowsmatched int4);" # Run tests function measureindexquality { cat <