Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D5737634C5A for ; Fri, 19 Mar 2010 13:31:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 91194-02 for ; Fri, 19 Mar 2010 16:30:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f227.google.com (mail-ew0-f227.google.com [209.85.219.227]) by mail.postgresql.org (Postfix) with ESMTP id 6109F63474C for ; Fri, 19 Mar 2010 13:30:57 -0300 (ADT) Received: by ewy27 with SMTP id 27so2356162ewy.34 for ; Fri, 19 Mar 2010 09:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=DOPyxSTOCFiitea6Hhwl6b5tiLC7Ch/5Ea4g6Nj/W3Y=; b=rzxm0nQtMs9vGuj8LXSNCEJfNQOkcEFAnSAVwYad3LNCjZBlJMzd3AqASqV6pjS6ql 9fU80Xjva/MQFZqgwym+98qjsEe0LJ8hvnVjmaqI0e4+jEG1fOOJTueDF/fcOhhf5ngu sMIbm1pfOf8H1wIUi90GKPWDb6L6MRNC2lF/Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=Avtp82WpSMK5eRoPrYrmfsLUtvwl6WQWgZbZmJXnMr2Q6az/KbqMHMfaSBMF8auXl4 ejfvXkfROa/qAgE+GiWL4aY0rlJQlyuI8XkIkzeAQjap3v74/zkBQwOxUITmmY8eYhb8 yYkoNcCNKB4hkCSfh++LfDX+jYAU3tyb69P3A= Received: by 10.213.1.143 with SMTP id 15mr590662ebf.55.1269016256461; Fri, 19 Mar 2010 09:30:56 -0700 (PDT) Received: from [0.0.0.0] (5357DA75.cable.casema.nl [83.87.218.117]) by mx.google.com with ESMTPS id 14sm498187ewy.14.2010.03.19.09.30.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 19 Mar 2010 09:30:55 -0700 (PDT) Message-ID: <4BA3A6C6.80406@gmail.com> Date: Fri, 19 Mar 2010 17:31:02 +0100 From: Yeb Havinga User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Matthew Wakeling CC: Bruce Momjian , pgsql-performance@postgresql.org Subject: Re: GiST index performance References: <201002252342.o1PNgtG07127@momjian.us> <4B9FAF4B.20907@gmail.com> <4BA0A036.1070508@gmail.com> In-Reply-To: <4BA0A036.1070508@gmail.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=-2.223 tagged_above=-10 required=5 tests=AWL=0.061, BAYES_00=-2.599, SARE_MILLIONSOF=0.315 X-Spam-Level: X-Archive-Number: 201003/240 X-Sequence-Number: 38065 Yeb Havinga wrote: > Yeb Havinga wrote: >> Matthew Wakeling wrote: >>>> Matthew Wakeling wrote: >>>>> A second quite distinct issue is the general performance of GiST >>>>> indexes >>>>> which is also mentioned in the old thread linked from Open Items. For >>>>> that, we have a test case at >>>>> http://archives.postgresql.org/pgsql-performance/2009-04/msg00276.php >>>>> for >>>>> btree_gist indexes. I have a similar example with the bioseg GiST >>>>> index. I >>>>> have completely reimplemented the same algorithms in Java for >>>>> algorithm >>>>> investigation and instrumentation purposes, and it runs about a >>>>> hundred >>>>> times faster than in Postgres. I think this is a problem, and I'm >>>>> willing >>>>> to do some investigation to try and solve it. >>> I have not made any progress on this issue. I think Oleg and Teodor >>> would be better placed working it out. All I can say is that I >>> implemented the exact same indexing algorithm in Java, and it >>> performed 100 times faster than Postgres. Now, Postgres has to do a >>> lot of additional work, like mapping the index onto disc, locking >>> pages, and abstracting to plugin user functions, so I would expect >>> some difference - I'm not sure 100 times is reasonable though. I >>> tried to do some profiling, but couldn't see any one section of code >>> that was taking too much time. Not sure what I can further do. > Looked in the code a bit more - only the index nodes are compressed at > index creation, the consistent functions does not compress queries, so > not pallocs there. However when running Mathews example from > http://archives.postgresql.org/pgsql-performance/2009-04/msg00276.php > with the gist index, the coverage shows in gistget.c: 1000000 palloc0 > 's of gistsearchstack at line 152 and 2010982 palloc's also of the > gistsearchstack on line 342. Two pfrees are also hit a lot: line 195: > 1010926 of a stackentry and line 293: 200056 times. My $0.02 cents is > that the pain is here. My knowledge of gistget or the other sources in > access/gist is zero, but couldn't it be possible to determine the > maximum needed size of the stack and then allocate it at once and use > a pop/push kind off api? Waisted some time today on a ghost chase... I though that removing the millions of pallocs would help, so I wrote an alternative of the gistsearchstack-stack to find out that it was not the index scanning itself that caused milltions of pallocs, but the scan being in the inner loop that was called 1000000 times. The actual scanning time was not changed significantly. The actual scanning time in my vm is for btree (actual time=0.006..0.008) and gist (actual time=0.071..0.074). An error in my searchstack alternative caused pages to be scanned twice, returing twice the amount of rows (6 instead of 3 each time). This resulted in a likewise increase of ms (actual time=0.075..0.150). Somewhere I hit something that causes ~= 0.070 ms twice. For a single index scan, 0.070ms startup time for gist vs 0.006 for btree doesn't seem like a big problem, but yeah when calling it a million times... regards, Yeb Havinga