"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