From: Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
To: Lista Postgres <pgsql-admin@postgresql.org>
Subject: Is unique index always used if query is on first constituent column ?
Date: Sat, 30 Dec 2006 16:08:39 +0530
Message-ID: <a97c77030612300238j47f7e52bxb23fe644f0046094@mail.gmail.com> (raw)
Hi,
suppose we have 2 columns a and b . we need to query by a and sometimes
by b for data consistency UNIQUE(a,b) also needs to be there. we create
indexes below:
create unique index ab on t(a,b);
create index b on t(b);
it has been observed that index ab is used while querying
for a , can we always avoid creating the extra index on a ie,
create index a on t(a); (does other databases also behave
similar?)
Regds
mallah.
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-admin@postgresql.org
Cc: mallah.rajesh@gmail.com
Subject: Re: Is unique index always used if query is on first constituent column ?
In-Reply-To: <a97c77030612300238j47f7e52bxb23fe644f0046094@mail.gmail.com>
References: <a97c77030612300238j47f7e52bxb23fe644f0046094@mail.gmail.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