From: Michele Bendazzoli <mickymouse@mickymouse.it>
To: pgsql-sql@postgresql.org
Subject: Multicolum index and primary key
Date: Mon, 17 Nov 2003 18:00:32 +0100
Message-ID: <1069088432.8338.16.camel@mickymouse.sintel> (raw)
I wonder if is useless to set some indexes for columns contained in a
multifield primary key.
Suppose by example that one have a table1 with a primary key over three
field (a, b, c):
ALTER TABLE public.table1
ADD CONSTRAINT table1_pkey PRIMARY KEY(a, b, c);
are the indexes over (a) and (a, b) redundant (and so useless)?
I.e. with other words the question is, if I have a primary key set for
the a, b, c fields the queries
SELECT 1 from table1 where a='a value'
and
SELECT 1 from table1 where a='a value' AND b='another value'
use the implicit index created by the primary key or not?
Thank you in advance for any advice.
ciao, Michele
p.s. I know, I'll have to begin to use the explain command ...
I promise I'll do it ;-)
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mickymouse@mickymouse.it
Subject: Re: Multicolum index and primary key
In-Reply-To: <1069088432.8338.16.camel@mickymouse.sintel>
* 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