Re: Queryplan within FTS/GIN index -search.

From: Jesper Krogh <jesper(at)krogh(dot)cc>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Queryplan within FTS/GIN index -search.
Date: 2009-10-23 18:12:51
Message-ID: 4AE1F223.2010701@krogh.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Jeff Davis wrote:
> On Fri, 2009-10-23 at 09:45 +0200, jesper(at)krogh(dot)cc wrote:
>> No, it definately has to go visit the index/table to confirm findings, but
>> that why I wrote Queryplan in the subject line, because this os only about
>> the strategy to pursue to obtain the results. And a strategy about
>> limiting the amout of results as early as possible (as PG usually does)
>> would be what I'd expect and MCV can help it guess on that.
>
> I see what you're saying: you could still index the common terms like
> normal, but just not look for anything in the index if it's an MCV. That
> sounds reasonable, based on the numbers you provided.

I'm not sure if thats what I'm saying. If i should rephrase it then:
Given an AND operator (which translates into an intersection of the left
and right side), then it should go for the side with the least expected
results (SetLeast) and subsequent use the other expression for
processing only that set.

>> Index Cond: (ftsbody_body_fts @@ to_tsquery('commonterm &
>> spellerror'::text))
>> Total runtime: 862.771 ms
>> (6 rows)
>
> ...
>
>> Index Cond: ((ftsbody_body_fts @@
>> to_tsquery('commonterm'::text)) AND (ftsbody_body_fts @@
>> to_tsquery('spellerror'::text)))
>> Total runtime: 8.724 ms
>> (6 rows)
>>
>
> Something seems strange here. Both are a single index scan, but having a
> single complex search key is worse than having two simple search keys.
>
> Perhaps the real problem is that there's a difference between these
> cases at all? I don't see any reason why the first should be more
> expensive than the second.

--
Jesper

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jesper Krogh 2009-10-23 18:38:56 Calculating selectivity for the query-planner on ts_vector colums.
Previous Message Richard Huxton 2009-10-23 16:27:54 Re: Queryplan within FTS/GIN index -search.