Re: [PATCH] Partial indicies almost working (I think)

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [PATCH] Partial indicies almost working (I think)
Date: 2001-07-05 01:15:39
Message-ID: 20010705111539.A10153@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jul 04, 2001 at 11:37:36AM -0400, Tom Lane wrote:
> 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.

Done that, see my other email.

> > 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?

Well, index->tuples has the number of tuples in the index. By matching I
meant that matching the predicate on the index.

> 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.

See my other email. All I've done is let the normal estimator estimate the
number of rows based on the whole table and then capped it if it comes out
more than the number of rows in the index.

I think the only real way to do it would be to keep seperate statistics for
the part matching the predicate, since it can be considered to be a separate
table, but that requires a few bigger changes. It gets it pretty right at
the moment.

--
Martijn van Oosterhout <kleptog(at)svana(dot)org>
http://svana.org/kleptog/
> It would be nice if someone came up with a certification system that
> actually separated those who can barely regurgitate what they crammed over
> the last few weeks from those who command secret ninja networking powers.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-07-05 01:38:12 Re: PostgreSQL ports post-installation gives core dump?
Previous Message CD Baby 2001-07-05 01:00:57 PostgreSQL ports post-installation gives core dump?