From: Gerald Gutierrez <gutz@kalador.com>
To: pgsql-sql@postgresql.org
Subject: Appropriate indices to create for these queries
Date: Mon, 2 Apr 2001 18:49:44 -0700
Message-ID: <IIEOKIIOJMELMIFMMEBFOEILCAAA.gutz@kalador.com> (raw)
I've been looking into indices and which ones to create and I'm getting
myself a little confused. The "PostgreSQL Introduction and Concepts" book
didn't help very much. I wonder if a kind soul can give me some tips.
SELECT * FROM T1 WHERE a=1 and b='hello';
Is the appropriate index for this query:
CREATE INDEX ndx ON T1 (a, b) ?
When I was testing, it seemed that even if I created the index with only
"a", EXPLAIN told me that it would just do an index scan, seemingly
indicating that it didn't matter whether I had an "a" index, or an "a, b"
index.
How about for WHERE a=1 or b='hello' and other more complex forms? Is there
documentation that describes a variety of different queries and what kind of
indices are best?
Thanks.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: gutz@kalador.com
Subject: Re: Appropriate indices to create for these queries
In-Reply-To: <IIEOKIIOJMELMIFMMEBFOEILCAAA.gutz@kalador.com>
References: <IIEOKIIOJMELMIFMMEBFOEILCAAA.gutz@kalador.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox