Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 600BA6340E0 for ; Tue, 1 Jun 2010 16:00:46 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 01841-03-6 for ; Tue, 1 Jun 2010 19:00:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from spinlock.commandprompt.com (host-215.commandprompt.net [207.173.203.215]) by mail.postgresql.org (Postfix) with ESMTP id 30969634226 for ; Tue, 1 Jun 2010 16:00:36 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by spinlock.commandprompt.com (Postfix) with ESMTP id 21DDA34C215; Tue, 1 Jun 2010 12:00:34 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at commandprompt.com Received: from spinlock.commandprompt.com ([127.0.0.1]) by localhost (spinlock.commandprompt.com.commandprompt.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZWSxmZxZRMbf; Tue, 1 Jun 2010 12:00:29 -0700 (PDT) Received: from perhan.alvh.no-ip.org (190-95-18-247.bk17-dsl.surnet.cl [190.95.18.247]) by spinlock.commandprompt.com (Postfix) with ESMTPSA id F345F348002; Tue, 1 Jun 2010 12:00:28 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D94186E8AB; Tue, 1 Jun 2010 15:00:26 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: pgsql-performance Subject: Re: Optimize date query for large child tables: GiST or GIN? From: Alvaro Herrera To: David Jarvis In-reply-to: References: <7143.1274382139@sss.pgh.pa.us> <7767.1274385170@sss.pgh.pa.us> <7917.1274385834@sss.pgh.pa.us> <8132.1274386738@sss.pgh.pa.us> <1275412319-sup-2359@alvh.no-ip.org> Date: Tue, 01 Jun 2010 15:00:26 -0400 Message-Id: <1275418606-sup-7720@alvh.no-ip.org> User-Agent: Sup/0.11 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.5 tagged_above=-10 required=5 tests=BAYES_05=-0.5 X-Spam-Level: X-Archive-Number: 201006/11 X-Sequence-Number: 38867 Excerpts from David Jarvis's message of mar jun 01 14:01:22 -0400 2010: > Sorry, Alvaro. > > I was contemplating using a GIN or GiST index as a way of optimizing the > query. My fault -- I didn't read the whole thread. > Instead, I found that re-inserting the data in order of station ID (the > primary look-up column) and then CLUSTER'ing on the station ID, taken date, > and category index increased the speed by an order of magnitude. Hmm, that's nice, though I cannot but wonder whether the exclusive lock required by CLUSTER is going to be a problem in the long run. > I might be able to drop the station/taken/category index in favour of the > simple station index and CLUSTER on that, instead (saving plenty of disk > space). Either way, it's fast right now so I'm not keen to try and make it > much faster. Hm, keep in mind that if the station clause alone is not selective enough, scanning it may be too expensive. The current three column index is probably a lot faster to search (though of course it's causing more work to be kept up to date on insertions). -- Álvaro Herrera The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support