Re: Index problem.... GIST (tsearch2) - Mailing list pgsql-general

From Greg Stark
Subject Re: Index problem.... GIST (tsearch2)
Date
Msg-id 87ekka6qsq.fsf@stark.xeocode.com
Whole thread Raw
In response to Index problem.... GIST (tsearch2)  ("Net Virtual Mailing Lists" <mailinglists@net-virtual.com>)
Responses Re: Index problem.... GIST (tsearch2)
List pgsql-general
"Net Virtual Mailing Lists" <mailinglists@net-virtual.com> writes:

> SELECT * from sometable WHERE is_null(category1)='f' AND data_fti @@
> to_tsquery('default', 'postgres');
>
> How can I make this query first use the is_null index?... It strikes me
> that this would almost always be faster then doing the full-text search
> first, right?...

Well that depends on how many are false versus how many the full-text search
finds.

In this circumstance postgres is trying to compare two unknowns. It doesn't
know how often is_nul() is going to return false, and it doesn't know how many
records the full text search will match.

8.0 will have statistics on how often is_null() will return false. But that
isn't really going to solve your problem since it still won't have any idea
how many rows the full text search will find.

I don't even know of anything you can do to influence the selectivity
estimates of the full text search.

--
greg

pgsql-general by date:

Previous
From: David Fetter
Date:
Subject: Re: regular expression searches
Next
From: "Kiarash Bodouhi"
Date:
Subject: Question from a newbie