Re: [PGSQL 8.3.5] Use of a partial indexes

From: justin <justin(at)emproshunts(dot)com>
To: Reg Me Please <regmeplease(at)gmail(dot)com>
Cc: Scott Ribe <scott_ribe(at)killerbytes(dot)com>, "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: [PGSQL 8.3.5] Use of a partial indexes
Date: 2008-12-30 14:18:36
Message-ID: 495A2DBC.7040501@emproshunts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Reg Me Please wrote:
> Only one question remains in my mind:
>
> why the planner is not using the partial index?
>
> The partial index is covering 2 predicates out of the 3 used in the where
> condition. Actually there is a boolean flag (to exclude "disabled" rows),
> a timestamp (for row age) and an int8 (a FK to another table).
> The first two are in the partial index in order to exclude "disabled" and
> older rows. The int8 is the "random" key I mentioned earlier.
>
> So the WHERE condition reads like:
>
> flag AND tstz >= '2008-01-01'::timestamptz and thekey=42
>
> I can see in the EXPLAIN that there is no mention to the partial index.
> Please keep in mind that the table has 8+M rows, few of which are flagged,
> about 70% don't match the age limit and few dozens match the key.
> In my opinion the partial index should help a lot.
>
> --
> Fahrbahn ist ein graues Band
> weisse Streifen, grüner Rand
>
>
For an index to be used the where clause must match the index. As the
index gets more complicated its less likely to be used.

I have 5 indexes on one table to answer the 5 possible ways the where
clause can look like.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2008-12-30 15:39:23 Re: Load Image File From PostgreSQL DB
Previous Message Scott Marlowe 2008-12-30 14:12:33 Re: [PGSQL 8.3.5] Use of a partial indexes