Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id DD9E99FB9B2 for ; Tue, 23 Oct 2007 08:18:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 37565-02 for ; Tue, 23 Oct 2007 08:18:38 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 66FDB9FB54D for ; Tue, 23 Oct 2007 08:18:44 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IkHlX-0003Y2-4s for pgsql-performance@postgresql.org; Tue, 23 Oct 2007 11:17:43 +0000 Received: from cpe.atm2-0-1261189.0x503fa7b2.bynxx8.customer.tele.dk ([80.63.167.178]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Oct 2007 11:17:43 +0000 Received: from nis by cpe.atm2-0-1261189.0x503fa7b2.bynxx8.customer.tele.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Oct 2007 11:17:43 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: =?ISO-8859-1?Q?Nis_J=F8rgensen?= Subject: Re: How to improve speed of 3 table join &group (HUGE tables) Date: Tue, 23 Oct 2007 13:16:46 +0200 Lines: 38 Message-ID: References: <4717914D.1050704@cbio.mskcc.org> <4717B80B.6050706@cbio.mskcc.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cpe.atm2-0-1261189.0x503fa7b2.bynxx8.customer.tele.dk User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) In-Reply-To: <4717B80B.6050706@cbio.mskcc.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/248 X-Sequence-Number: 27270 John Major skrev: > Hello Nis- > > I did reset the defaults before running the explain. This line from your original post: -> Seq Scan on sequence_alignment sa (cost=100000000.00..110379294.60 rows=467042560 width=4) Is an indication that you didn't (AFAIK enable_seqscan=off works by setting the cost of starting a seqscan to 100000000). > Candidate keys. > fragment_external_info.seq_frag_id (FK to sequence_fragment.seq_frag_id) > sequence_alignment.sequence_id (FK to sequence_fragment.sequence_id). Those are not candidate keys. A candidate key is "something which could have been chosen as the primary key". Anyway, I think I understand your table layout now. It might have been quicker if you just posted the definition of your tables. This could also have shown us that the correct indexes are in place, rather than taking your word for it. You are absolutely certain that both sides of all FK relationships are indexed? > After making the 2 changes, the cost dropped dramatically... but is still very high. > Original Explain cost: > cost=1308049564..1345206293 rows=54 width=16 > > New Explain cost: > cost=11831119..11831120 rows=54 width=16 Please post the full output if you want more help. And preferably use EXPLAIN ANALYZE, now that it runs in finite time. Nis