Re: Use of Indexes

Lists: pgsql-general
From: "Darrell A(dot) Sullivan, II" <darrell(at)flores-associates(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Use of Indexes
Date: 2005-06-09 15:08:04
Message-ID: 027201c56d05$09f0d790$3b01a8c0@WS01
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello,

I am trying out a few databases to determine which one would best suit a
project.

I was wondering if someone could answer a question about how PostgreSQL uses
indexes when performing queries. Particularly, I need to know if the query
optimizer will use more than index for a query or if it only uses one.

For instance, one of my tables (1 million records) contains a document
number, a document type, a received date, a review date, an entered date,
and an audited date.

If I want to retrieve the following pieces of data:

all of the documents of type 1 that were received yesterday
all of the documents of type 2 that were entered yesterday
all of the documents of type 2 that were reviewed yesterday

Would I be able to create individual indexes on type, received date, entered
date, and reviewed date and the optimizer would select the appropriate two
indexes, or would I have to create three composite indexes that would
include type-received, type-entered, and type-reviewed?

Thanks for the help.

Darrell


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Darrell A(dot) Sullivan, II" <darrell(at)flores-associates(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Use of Indexes
Date: 2005-06-12 18:47:01
Message-ID: 26637.1118602021@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

"Darrell A. Sullivan, II" <darrell(at)flores-associates(dot)com> writes:
> I was wondering if someone could answer a question about how PostgreSQL uses
> indexes when performing queries. Particularly, I need to know if the query
> optimizer will use more than index for a query or if it only uses one.

Versions through 8.0 can only use one index per query (per table). 8.1
will be smarter though.

regards, tom lane