Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 98172636DDF for ; Fri, 19 Mar 2010 17:49:38 -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 28674-05-6 for ; Fri, 19 Mar 2010 20:49:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f220.google.com (mail-ew0-f220.google.com [209.85.219.220]) by mail.postgresql.org (Postfix) with ESMTP id 2BCA8640850 for ; Fri, 19 Mar 2010 17:49:22 -0300 (ADT) Received: by ewy20 with SMTP id 20so947168ewy.21 for ; Fri, 19 Mar 2010 13:49:20 -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=OxF+XSiPKOa6XpdsIo5jrbsJesR2dzlZg4TSq9XM5nI=; b=vllyEmsbbA4biLaUVCoztlLOlNoYVc5L7zf1Bo8CD0rERlFEfiG0yUAOTcBzxxdOwm itprPq/BoyUc7T/rwSB7O7twRh8DsIQAR08eAoR5GW+USU/ZOl2aJ2wEml6FCICMZ/jD j+1UYnuoDjPTEjSYM3P3iZcePf4qanNSHmpAE= 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=M5X8dNeYLlZ+Fi7MjkazIK6gTgntPyjj5u0A99jkgb2MSgzWWU7ny4nVTKDjlIAp/R r/FKrV7OekQ6gGBqfzkA7JSX7eUXqqMzVczokwOhDEZgz/TyyN5jNiFCdNXi/a/Qihng EJW1F9OMjBNCPOiN7FSQLeV6erDZXWfowkgVE= Received: by 10.213.24.17 with SMTP id t17mr8989689ebb.19.1269031760378; Fri, 19 Mar 2010 13:49:20 -0700 (PDT) Received: from [0.0.0.0] (5357DA75.cable.casema.nl [83.87.218.117]) by mx.google.com with ESMTPS id 14sm646237ewy.6.2010.03.19.13.49.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 19 Mar 2010 13:49:19 -0700 (PDT) Message-ID: <4BA3E35A.1000905@gmail.com> Date: Fri, 19 Mar 2010 21:49:30 +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> <4BA3A6C6.80406@gmail.com> <4BA3DCA1.2010808@gmail.com> In-Reply-To: <4BA3DCA1.2010808@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.386 tagged_above=-10 required=5 tests=AWL=0.213, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/248 X-Sequence-Number: 38073 Yeb Havinga wrote: > > Since the gistpagesize is derived from the database blocksize, it > might be wise to set the blocksize low for this case, I'm going to > play with this a bit more. Ok, one last mail before it turns into spam: with a 1KB database blocksize, the query now runs in 30 seconds (original 70 on my machine, shared buffers 240MB). The per inner loop access time now 24 microsecs compared to on my machine original 74 microsecs with 8KB size and 8 for the btree scan. Not a bad speedup with such a simple parameter :-) postgres=# EXPLAIN ANALYSE SELECT * FROM a, b WHERE a.a BETWEEN b.b AND b.b + 2; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------- Nested Loop (cost=0.00..4169159462.20 rows=111109777668 width=8) (actual time=0.184..29540.355 rows=2999997 loops=1) -> Seq Scan on b (cost=0.00..47037.62 rows=999962 width=4) (actual time=0.024..1783.484 rows=1000000 loops=1) -> Index Scan using a_a on a (cost=0.00..2224.78 rows=111114 width=4) (actual time=0.021..0.024 rows=3 loops=1000000) Index Cond: ((a.a >= b.b) AND (a.a <= (b.b + 2))) Total runtime: 30483.303 ms (5 rows) postgres=# select gist_stat('a_a'); gist_stat ------------------------------------------- Number of levels: 5 + Number of pages: 47618 + Number of leaf pages: 45454 + Number of tuples: 1047617 + Number of invalid tuples: 0 + Number of leaf tuples: 1000000 + Total size of tuples: 21523756 bytes+ Total size of leaf tuples: 20545448 bytes+ Total size of index: 48760832 bytes+ (1 row)