partial unique index and the planner - Mailing list pgsql-general

From Michal Politowski
Subject partial unique index and the planner
Date
Msg-id 20090215175006.GA374@meep.pl
Whole thread Raw
Responses Re: partial unique index and the planner
Re: partial unique index and the planner
List pgsql-general
I'm using PostgreSQL 8.3.
Is it normal that plans using a scan on a partial unique index
estimate that much more than one row is returned?

Eg. I see:
 ->  Bitmap Index Scan on tmp_idx_oss_archive_object_id_current (cost=0.00..3.12 rows=4189 width=0)
where the tmp_idx_oss_archive_object_id_current index is a partial unique index.

The estimated row count would be correct for the whole table but obviously not for
the part covered by the unique index.

This happens to be a problem in this case because then the planner
prefers a sequence scan on a table joined to this one and a hash join to an index scan
and a nested loop join. Which takes hundreds of milliseconds instead of
one, so setting enable_hashjoin to false increases performance immensely.

--
Michał Politowski
Talking has been known to lead to communication if practiced carelessly.

pgsql-general by date:

Previous
From: Bjørn T Johansen
Date:
Subject: Re: How do I set the schema search path in a datasource config for a connection pool?
Next
From: Scott Marlowe
Date:
Subject: Re: partial unique index and the planner