X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2D1E9DA9BE for ; Thu, 22 Sep 2005 13:17:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20677-05 for ; Thu, 22 Sep 2005 16:17:37 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id EFFE0DA9BD for ; Thu, 22 Sep 2005 13:17:34 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8MGHW5u029638; Thu, 22 Sep 2005 12:17:32 -0400 (EDT) To: Antoine Bajolet Cc: pgsql-performance@postgresql.org Subject: Re: Nested Loop trouble : Execution time increases more 1000 time (long) In-reply-to: <432C3A86.5010000@free.fr> References: <432C3A86.5010000@free.fr> Comments: In-reply-to Antoine Bajolet message dated "Sat, 17 Sep 2005 17:47:18 +0200" Date: Thu, 22 Sep 2005 12:17:32 -0400 Message-ID: <29637.1127405852@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/243 X-Sequence-Number: 14551 Antoine Bajolet writes: > We are using postgresql in a search engine on an intranet handling > throusand of documents. > But we ave a big problem when users use more than two search key. I think you need to increase the statistics targets for your keywords table --- the estimates of numbers of matching rows are much too small: > -> Index Scan using keyword_pattern_key on keywords > k2 (cost=0.00..3.51 rows=1 width=4) (actual time=0.078..1.887 rows=75 > loops=1) > Index Cond: (((keyword)::text ~>=~ > 'exploitation'::character varying) AND ((keyword)::text ~<~ > 'exploitatioo'::character varying)) > Filter: ((keyword)::text ~~ 'exploitation%'::text) A factor-of-75 error is quite likely to mislead the planner into choosing a bad join plan. BTW, have you looked into using a real full-text-search engine (eg, tsearch2) instead of rolling your own like this? regards, tom lane