Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id C3DEBEC32BA for ; Thu, 12 Apr 2012 19:26:13 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SISSy-0005q6-I0 for pgsql-performance@postgresql.org; Thu, 12 Apr 2012 22:26:13 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q3CMPx1C006274; Thu, 12 Apr 2012 18:25:59 -0400 (EDT) To: Benoit Delbosc cc: pgsql-performance@postgresql.org Subject: Re: Slow fulltext query plan In-reply-to: <4F875293.1000100@nuxeo.com> References: <4F875293.1000100@nuxeo.com> Comments: In-reply-to Benoit Delbosc message dated "Fri, 13 Apr 2012 00:09:23 +0200" Date: Thu, 12 Apr 2012 18:25:59 -0400 Message-ID: <6273.1334269559@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201204/95 X-Sequence-Number: 46741 Benoit Delbosc writes: > EXPLAIN ANALYZE SELECT hierarchy.id > FROM hierarchy > JOIN fulltext ON fulltext.id = hierarchy.id, > TO_TSQUERY('whatever') query1, > TO_TSQUERY('whatever') query2 > WHERE (query1 @@ nx_to_tsvector(fulltext.fulltext)) OR (query2 @@ > nx_to_tsvector(fulltext.fulltext_title)); Is there a reason why you're writing the query in such a non-straightforward way, rather than just EXPLAIN ANALYZE SELECT hierarchy.id FROM hierarchy JOIN fulltext ON fulltext.id = hierarchy.id WHERE (TO_TSQUERY('whatever') @@ nx_to_tsvector(fulltext.fulltext)) OR (TO_TSQUERY('whatever') @@ nx_to_tsvector(fulltext.fulltext_title)); ? regards, tom lane