Re: [PATCH] Partial indicies almost working (I think) - Mailing list pgsql-general

From Tom Lane
Subject Re: [PATCH] Partial indicies almost working (I think)
Date
Msg-id 27694.994261056@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] Partial indicies almost working (I think)  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: [PATCH] Partial indicies almost working (I think)  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Martijn van Oosterhout <kleptog@svana.org> writes:
> OK, so how to fix this. It seems to me that all that is required is that for
> partial indicies it should try to add a path for a plain index scan over the
> index and let the cost estimator decide if it's cheaper than a sequential
> scan.

Probably a reasonable first cut: if the index predicate fits, then always
generate a path.  This assumes that partial indexes are usually made to
cover relatively small fractions of the table, but I'm willing to
believe that for starters.

> only thing is, will the cost estimator get it right. At least the partial
> index has an accurate count of the number of matching rows.

Why would you think that?

I can pretty much guarantee that the cost estimator will *not* get it
right --- it has no idea about partial indexes.  You'll need to do some
fooling with the index selectivity estimation routines to account for
the effects of the predicate.

            regards, tom lane

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Please add to TODO list
Next
From: Marc SCHAEFER
Date:
Subject: NOT IN issue