Re: Indexes with condition using immutable functions applied to column not used

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: sylvain(at)abstraction(dot)fr
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Indexes with condition using immutable functions applied to column not used
Date: 2011-02-27 18:21:02
Message-ID: AANLkTinEjAWSD8cObVgS1-YrnVS=7TScCGkpRWEQ0DHs@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, Feb 7, 2011 at 7:14 PM, Sylvain Rabot <sylvain(at)abstraction(dot)fr> wrote:
> First I would like to know if there is more advantage than overhead to
> split an index in several ones using conditions

I don't see why that would be any better than just defining one big index.

> e.g. doing :
>
> CREATE INDEX directory_id_user_0_btree_idx ON mike.directory USING btree (id_user) WHERE id_user < 250000;
> CREATE INDEX directory_id_user_250000_btree_idx ON mike.directory USING btree (id_user) WHERE id_user >= 250000 AND id_user < 500000;
> CREATE INDEX directory_id_user_500000_btree_idx ON mike.directory USING btree (id_user) WHERE id_user >= 500000 AND id_user < 750000;
> CREATE INDEX directory_id_user_750000_btree_idx ON mike.directory USING btree (id_user) WHERE id_user >= 750000 AND id_user < 1000000;
>
> instead of having only one index for all the id_user. the forecasts for
> the table directory are +500 millions records and something like 1
> million distinct id_user.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2011-02-27 18:39:41 Re: Bad query plan when the wrong data type is used
Previous Message Robert Haas 2011-02-27 18:16:55 Re: Bad query plan when the wrong data type is used