Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wcwmk-0006UJ-1N for pgsql-performance@arkaria.postgresql.org; Wed, 23 Apr 2014 13:00:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wcwmj-00006L-Go for pgsql-performance@arkaria.postgresql.org; Wed, 23 Apr 2014 13:00:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wcwmi-0008WV-0K for pgsql-performance@postgresql.org; Wed, 23 Apr 2014 13:00:20 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wcwme-00018x-2L for pgsql-performance@postgresql.org; Wed, 23 Apr 2014 13:00:19 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id DB08F28170; Wed, 23 Apr 2014 06:00:13 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id D4A8C19249; Wed, 23 Apr 2014 06:00:13 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 40D70120033; Wed, 23 Apr 2014 06:00:05 -0700 (PDT) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA; Wed, 23 Apr 2014 06:00:04 -0700 (PDT) Message-ID: <5357B95B.2050008@vmware.com> Date: Wed, 23 Apr 2014 16:00:11 +0300 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.4.0 MIME-Version: 1.0 To: Ivan Voras CC: postgres performance list Subject: Re: tsearch2, large data and indexes References: <53560EE5.3080300@vmware.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.6 (-------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 04/22/2014 10:57 AM, Ivan Voras wrote: > On 22 April 2014 08:40, Heikki Linnakangas wrote: >> On 04/20/2014 02:15 AM, Ivan Voras wrote: >>> More details: after thinking about it some more, it might have >>> something to do with tsearch2 and indexes: the large data in this case >>> is a tsvector, indexed with GIN, and the query plan involves a >>> re-check condition. >>> >>> The query is of the form: >>> SELECT simple_fields FROM table WHERE fts @@ to_tsquery('...'). >>> >>> Does the "re-check condition" mean that the original tsvector data is >>> always read from the table in addition to the index? >> >> Yes, if the re-check condition involves the fts column. I don't see why you >> would have a re-check condition with a query like that, though. Are there >> some other WHERE-conditions that you didn't show us? > > Yes, I've read about tsearch2 and GIN indexes and there shouldn't be a > recheck condition - but there is. > This is the query: > > SELECT documents.id, title, raw_data, q, ts_rank(fts_data, q, 4) AS > rank, html_filename > FROM documents, to_tsquery('document') AS q > WHERE fts_data @@ q > ORDER BY rank DESC LIMIT 25; It's the ranking that's causing the detoasting. "ts_rank(fts_data, q, 4)" has to fetch the contents of the fts_data column. Sorry, I was confused earlier: the "Recheck Cond:" line is always there in the EXPLAIN output of bitmap index scans, even if the recheck condition is never executed at runtime. It's because the executor has to be prepared to run the recheck-condition, if the bitmap grows large enough to become "lossy", so that it only stores the page numbers of matching tuples, not the individual tuples - Heikki -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance