X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 20CBB9DC882 for ; Wed, 11 Jan 2006 21:00:56 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32647-06 for ; Wed, 11 Jan 2006 21:00:58 -0400 (AST) X-Greylist: delayed 00:23:45.74358 by SQLgrey- Received: from imsm058dat.netvigator.com (imsm058.netvigator.com [218.102.48.211]) by postgresql.org (Postfix) with ESMTP id 5E80E9DC839 for ; Wed, 11 Jan 2006 21:00:52 -0400 (AST) Received: from n2.netvigator.com ([218.103.176.100]) by imsm057dat.netvigator.com (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20060112003708.MPBW14795.imsm057dat.netvigator.com@n2.netvigator.com> for ; Thu, 12 Jan 2006 08:37:08 +0800 Received: from n2.netvigator.com ([127.0.0.1]) by [127.0.0.1] with ESMTP (SpamPal v1.591) sender ; 12 Jan 2006 08:37:08 +???? Message-Id: <6.2.1.2.0.20060112083033.02bb74c8@localhost> X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 Date: Thu, 12 Jan 2006 08:36:19 +0800 To: pgsql-performance@postgresql.org From: K C Lau Subject: Re: indexes on primary and foreign keys In-Reply-To: <20060111232157.GA88829@winnie.fuhr.org> References: <1b8a973c0601111438m3e0b1cc0hf9c387a4a1d6791d@mail.gmail.com> <20060111232157.GA88829@winnie.fuhr.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.44 required=5 tests=[DNS_FROM_RFC_POST=1.44] X-Spam-Score: 1.44 X-Spam-Level: * X-Archive-Number: 200601/142 X-Sequence-Number: 16620 At 07:21 06/01/12, Michael Fuhr wrote: >On Wed, Jan 11, 2006 at 02:38:42PM -0800, Burak Seydioglu wrote: > > I do a load of sql joins using primary and foreign keys. What i would like > > to know if PostgreSQL creates indexes on these columns automatically (in > > addition to using them to maintain referential integrity) or do I have to > > create an index manually on these columns as indicated below? > > > > CREATE TABLE cities ( > > city_id integer primary key, > > city_name varchar(50) > > ); > > > > CREATE INDEX city_id_index ON cities(city_id); > >PostgreSQL automatically creates indexes on primary keys. If you run >the above CREATE TABLE statement in psql you should see a message to >that effect: > >NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >"cities_pkey" for table "cities" Is there a way to suppress this notice when I create tables in a script? Best regards, KC.