Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 3EA42EC32BA for ; Thu, 12 Apr 2012 19:56:30 -0300 (ADT) Received: from mail-we0-f174.google.com ([74.125.82.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SISwG-0006FR-VK for pgsql-performance@postgresql.org; Thu, 12 Apr 2012 22:56:30 +0000 Received: by wejx9 with SMTP id x9so1564600wej.19 for ; Thu, 12 Apr 2012 15:56:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:organization:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding:x-gm-message-state; bh=vqHQlDosyN21n2WXIKuKQVJZQatZ6McQhmlKcnu5e68=; b=Agkt4bPSDLOpIV1TShCtYvuFiB3gE7WGCKWSg6w45QSKrJsqHfA/i0GGV+xMs/g/6F 7QS8bb65eMYV7d0LhOysvvxGYgQD3zitB0+1W3zR4h9mYmJRNhL/UZsMp+e8aVvnAgpt NyU5FFPGis2uFkslror3ojoPTMXdvPEV9D0ZI76+dgXYoeiNuA5dQP/YHtPrET3XO5ND S6S/uCeQAcOYS4GX4hppRLnCvnvoV+EMd2r0w3HpQCJYczOFXknIn22qq/AzjHT4/WgJ SDMP3HjxAw5NJ7y92T2Ifl2n4CECoP7YQqq9/wCN75eCe5elLBNu01pTlYRxbpNqlel5 pJvg== Received: by 10.180.95.34 with SMTP id dh2mr71233wib.15.1334271375330; Thu, 12 Apr 2012 15:56:15 -0700 (PDT) Received: from [192.168.1.100] (7.167.73.86.rev.sfr.net. [86.73.167.7]) by mx.google.com with ESMTPS id gg2sm930139wib.7.2012.04.12.15.56.12 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Apr 2012 15:56:14 -0700 (PDT) Message-ID: <4F875D8B.6020802@nuxeo.com> Date: Fri, 13 Apr 2012 00:56:11 +0200 From: Benoit Delbosc Organization: Nuxeo User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.28) Gecko/20120313 Lightning/1.0b2 Thunderbird/3.1.20 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Slow fulltext query plan References: <4F875293.1000100@nuxeo.com> <6273.1334269559@sss.pgh.pa.us> In-Reply-To: <6273.1334269559@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQkjFVY/CYUR1TILt6drxkva3TVEztBjBpZrBskzb7oceoW8x/scliyzBT7+ZUzTYG6isMja X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201204/96 X-Sequence-Number: 46742 On 13/04/2012 00:25, Tom Lane wrote: > 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)); > > ? > This query is written by a framework, also I thought that is a common pattern that can be found in the documentation: http://www.postgresql.org/docs/9.1/interactive/textsearch-controls.html if you think this a wrong way to do it then I will try to fix the framework. btw your version takes 15ms :) Thanks ben