X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id B747FCC544 for ; Fri, 11 Jul 2003 17:23:49 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 47366-02 for ; Fri, 11 Jul 2003 14:23:36 -0300 (ADT) Received: from mail-2.zoominternet.net (unknown [63.67.120.12]) by svr1.postgresql.org (Postfix) with SMTP id 0B941CCA1B for ; Fri, 11 Jul 2003 14:20:41 -0300 (ADT) Received: (qmail 4776 invoked from network); 11 Jul 2003 17:20:59 -0000 Received: from acs-24-154-209-142.zoominternet.net (HELO gmod.lajolla) ([24.154.209.142]) (envelope-sender ) by mail-2.zoominternet.net (qmail-ldap-1.03) with SMTP for ; 11 Jul 2003 17:20:59 -0000 Subject: Re: force the use of a particular index From: Scott Cain To: Rod Taylor Cc: Postgresql Performance In-Reply-To: <1057940450.65544.14.camel@jester> References: <1057850280.1451.22.camel@localhost.localdomain> <1057920672.46100.149.camel@jester> <1057929459.5766.7.camel@localhost.localdomain> <1057930695.46100.172.camel@jester> <1057937779.5767.17.camel@localhost.localdomain> <1057940450.65544.14.camel@jester> Content-Type: text/plain Organization: Cold Spring Harbor Lab Message-Id: <1057944059.5766.34.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.0 Date: 11 Jul 2003 13:20:59 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/176 X-Sequence-Number: 2469 On Fri, 2003-07-11 at 12:20, Rod Taylor wrote: > On Fri, 2003-07-11 at 11:36, Scott Cain wrote: > > Any other ideas? > > Out of curiosity, what do you get if you disable hash joins? > > set enable_hashjoin = false; BINGO! QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Unique (cost=161718.69..161738.38 rows=113 width=53) (actual time=529.03..529.03 rows=1 loops=1) -> Sort (cost=161718.69..161721.50 rows=1125 width=53) (actual time=529.02..529.02 rows=1 loops=1) Sort Key: f.name, fl.fmin, fl.fmax, fl.strand, f.type_id, f.feature_id -> Merge Join (cost=26493.64..161661.65 rows=1125 width=53) (actual time=416.46..528.77 rows=1 loops=1) Merge Cond: ("outer".feature_id = "inner".feature_id) -> Index Scan using feature_pkey on feature f (cost=0.00..134592.43 rows=47912 width=39) (actual time=0.46..502.50 rows=431 loops=1) Filter: (type_id = 219) -> Sort (cost=26493.64..26722.33 rows=91476 width=14) (actual time=23.98..24.38 rows=570 loops=1) Sort Key: fl.feature_id -> Index Scan using featureloc_src_6 on featureloc fl (cost=0.00..18039.22 rows=91476 width=14) (actual time=15.16..21.85 rows=570 loops=1) Index Cond: ((fmin <= 2585581) AND (fmax >= 2565581)) Filter: (srcfeature_id = 6) Total runtime: 529.52 msec (13 rows) > > How about a partial index on (feature_id) where type_id = 219? That is a possiblity. type_id is a foreign key on another table that has several thousand rows, but in practice, there will be only a subset of those that we are interested in using with this query, so it may not be too unwieldy to do for each interesting type_id in practice. However, for testing I just created the partial index on type_id=219 and it was not used, so it may not make a difference anyway. Thanks much, Scott -- ------------------------------------------------------------------------ Scott Cain, Ph. D. cain@cshl.org GMOD Coordinator (http://www.gmod.org/) 216-392-3087 Cold Spring Harbor Laboratory