X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E14BCD1B584 for ; Mon, 17 Nov 2003 15:53:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 92976-08 for ; Mon, 17 Nov 2003 11:53:19 -0400 (AST) Received: from woodfire (ip-a1-37118.keycomm.it [62.152.37.118]) by svr1.postgresql.org (Postfix) with ESMTP id 7BE28D1D861 for ; Mon, 17 Nov 2003 11:53:13 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by woodfire (Postfix) with ESMTP id D2234318 for ; Mon, 17 Nov 2003 17:55:47 +0100 (CET) Received: from woodfire ([127.0.0.1]) by localhost (woodfire [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03495-10 for ; Mon, 17 Nov 2003 17:55:41 +0100 (CET) Received: from osts (unknown [192.168.100.27]) by woodfire (Postfix) with ESMTP id 238ED1AA for ; Mon, 17 Nov 2003 17:55:41 +0100 (CET) Subject: Multicolum index and primary key From: Michele Bendazzoli To: pgsql-sql@postgresql.org Content-Type: text/plain Organization: Micky Mouse Message-Id: <1069088432.8338.16.camel@mickymouse.sintel> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 17 Nov 2003 18:00:32 +0100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at sintelnet.it X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/198 X-Sequence-Number: 16013 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 ;-)