Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BD46C47589A for ; Sun, 11 Aug 2002 17:41:44 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 34F9E4750F5 for ; Sun, 11 Aug 2002 17:41:44 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g7BLfZVk023740; Sun, 11 Aug 2002 17:41:35 -0400 (EDT) To: Chris Mungall Cc: pgsql-admin@postgresql.org Subject: Re: abnormally long time in performing a two-table join In-reply-to: References: Comments: In-reply-to Chris Mungall message dated "Sun, 11 Aug 2002 14:18:02 -0700" Date: Sun, 11 Aug 2002 17:41:35 -0400 Message-ID: <23739.1029102095@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/107 X-Sequence-Number: 5222 Chris Mungall writes: > Nested Loop (cost=0.00..197011.39 rows=223 width=8) (actual time=16744.92..44572.00 rows=15 loops=1) > -> Index Scan using seqfeature_pkey on seqfeature (cost=0.00..61715.62 rows=44674 width=4) (actual time=0.29..14669.06 rows=100030 loops=1) > -> Index Scan using sfqv_idx1 on sfqv (cost=0.00..3.02 rows=1 width=4) (actual time=0.29..0.29 rows=0 loops=100030) Odd ... I'm surprised it doesn't choose a hash join. What do you get if you try it with "set enable_nestloop = off" ? > CREATE INDEX sfqv_idx4 ON sfqv USING btree (seqfeature_id, qualifier_value); > I would have thought sfqv_idx4 would be useful in this particular query? You'd have to write select ... where qualifier_value = 'BRCA1' and seqfeature.seqfeature_key_id = 15 and sfqv.seqfeature_key_id = 15 to get it to consider that index. You know and I know that the join should imply sfqv.seqfeature_key_id = 15, but the planner doesn't. regards, tom lane