Re: multicolumn index vs two indexes

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: <salva(at)ronincoders(dot)com>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: multicolumn index vs two indexes
Date: 2001-03-02 19:16:25
Message-ID: Pine.LNX.4.30.0103022014190.775-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Salvador Mainé writes:

> I have a table whith an id field, a date field and 5 millions rows. I
> need make queries like
>
> select *on table where id='001' and fecha >='1-1-1999' and fecha
> <'1-1-2000';
>
> What is better? To create a multicolumn btree index with (date, id) or
> two indexes, one btree for the date and a hash for the id?

A query can only use at most one index, so two indices is out. Perhaps it
would also make sense to create an index on "id" only, depending on what
the selectivity is.

> Where can I find mor accurate info about indexes? (the manual is a
> little bit short of it).

Try the 7.1 manual:
http://www.postgresql.org/devel-corner/docs/postgres/indices.html

--
Peter Eisentraut peter_e(at)gmx(dot)net http://yi.org/peter-e/

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Christoph Lange 2001-03-03 00:02:15 Problems solved so far (Rookie in installation-trouble -> PLEEEASE HELP; Installation-trouble)
Previous Message Salvador Mainé 2001-03-02 19:02:16 multicolumn index vs two indexes