Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 19F349FC333 for ; Thu, 18 Oct 2007 16:07:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 63061-06 for ; Thu, 18 Oct 2007 16:07:21 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from mail01.enterprisedb.com (mail01.enterprisedb.com [63.246.7.168]) by postgresql.org (Postfix) with ESMTP id B36BA9FC315 for ; Thu, 18 Oct 2007 16:07:20 -0300 (ADT) thread-index: AcgRuiYdb8aybo3iSdWAN8AcDX4C8w== Received: from [192.168.1.33] ([82.3.250.62]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Oct 2007 15:07:37 -0400 Message-ID: <4717AEA3.7030507@enterprisedb.com> Date: Thu, 18 Oct 2007 20:06:11 +0100 Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 From: "Heikki Linnakangas" User-Agent: Icedove 1.5.0.12 (X11/20070730) MIME-Version: 1.0 To: "John Major" Cc: Subject: Re: How to improve speed of 3 table join &group (HUGE tables) References: <4717914D.1050704@cbio.mskcc.org> In-Reply-To: <4717914D.1050704@cbio.mskcc.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 Oct 2007 19:07:38.0000 (UTC) FILETIME=[260C7900:01C811BA] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/221 X-Sequence-Number: 27243 John Major wrote: > ~there are indexes on all of the fields being joined (but not on > library_id or clip_type ). ~Everything has been re-analyzed post index > creation > ~I've tried "set enable_seqscan=off" and set (join_table_order or > something) = 1 Seqscanning and sorting a table is generally faster than a full scan of the table using an index scan, unless the heap is roughly in the index order. You probably need to CLUSTER the tables to use the indexes effectively. Are you sure you have an index on sequence_alignment.sequence_id? The planner seems to choose a seqscan + sort, even though you've set enable_seqscan=false. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com