From marcm@eisolution.com Mon Jan 28 16:42:27 2002 Received: from dg.eisolution.com (dsl-209-81-146-10.dsl.iwc.net [209.81.146.10]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0SGgRl59611 for ; Mon, 28 Jan 2002 11:42:27 -0500 (EST) (envelope-from marcm@eisolution.com) Received: from marcmdelltop (dsl-209-81-146-10.dsl.iwc.net [209.81.146.10]) by dg.eisolution.com (8.11.6/8.11.2) with SMTP id g0SGiXd25442 for ; Mon, 28 Jan 2002 10:44:33 -0600 Message-ID: <00d001c1a81a$d2fb86c0$7501050a@marcmdelltop> From: "Marc Mitchell" To: Subject: PRIMARY KEY Indexes. Date: Mon, 28 Jan 2002 10:42:45 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Archive-Number: 200201/218 X-Sequence-Number: 3102 pgsqlPostgres automatically creates a unique index to assure data integrity (see CREATE INDEX statement). The online docs at http://www.postgresql.org/idocs/index.php?sql-createtable.html state the following: " Postgres automatically creates a unique index to assure data integrity (see CREATE INDEX statement). " ... when PRIMARY KEY is specified within a CREATE TABLE statement. My questions: 1) Are these indexes at all visible to a tool like PGAdmin? How are they named? 2) If FORIGN KEY constraints were present on tables, I assume a lookup is done at time of INSERT to ensure the referenced value can be found. Would such a lookup and the index used be seen in the EXPLAIN or EXPLAIN VERBOSE output of an INSERT? For the record: OS is RedHat Linux 2.2.19 #8 SMP Fri Sep 21 10:04:24 CDT Postgres is PostgreSQL 7.1.2 on i686-pc-linux-gnu, compiled by GCC 2.96 -admin@postgresql.org From sszabo@megazone23.bigpanda.com Mon Jan 28 16:59:42 2002 Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0SGxgl64635 for ; Mon, 28 Jan 2002 11:59:42 -0500 (EST) (envelope-from sszabo@megazone23.bigpanda.com) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 8FDEFD5FF; Mon, 28 Jan 2002 08:59:53 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 8380D5BF8; Mon, 28 Jan 2002 08:59:53 -0800 (PST) Date: Mon, 28 Jan 2002 08:59:53 -0800 (PST) From: Stephan Szabo To: Marc Mitchell Cc: Subject: Re: PRIMARY KEY Indexes. In-Reply-To: <00d001c1a81a$d2fb86c0$7501050a@marcmdelltop> Message-ID: <20020128085350.V75869-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200201/220 X-Sequence-Number: 3104 On Mon, 28 Jan 2002, Marc Mitchell wrote: > pgsqlPostgres automatically creates a unique index to assure data integrity > (see CREATE INDEX statement). > > The online docs at > http://www.postgresql.org/idocs/index.php?sql-createtable.html state the > following: > > " Postgres automatically creates a unique index to assure data integrity > (see CREATE INDEX statement). " ... when PRIMARY KEY is specified within a > CREATE TABLE statement. > > My questions: > > 1) Are these indexes at all visible to a tool like PGAdmin? How are they > named? The name is _pkey. I'd assume they are visible assuming PGAdmin doesn't hide them and just show the primary key constraint. > 2) If FORIGN KEY constraints were present on tables, I assume a lookup is > done at time of INSERT to ensure the referenced value can be found. Would > such a lookup and the index used be seen in the EXPLAIN or EXPLAIN VERBOSE > output of an INSERT? It should generally use the index. There are cases due to the saved plan where the best plan might change during a session and we won't notice that until the next session. The explain output won't show the fk lookups as far as I know, however.