From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Thom Brown <thom@linux.com>
Cc: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-docs <pgsql-docs@postgresql.org>
Subject: Re: Primary Key index
Date: Thu, 26 Aug 2010 15:14:06 -0500
Message-ID: <4C7684BE0200002500034CDC@gw.wicourts.gov> (raw)
In-Reply-To: <AANLkTinUvsadhOhoRAU2v0S54Y0OFTW2yCsyBMuV9JKC@mail.gmail.com>
References: <AANLkTi=zsckLwmTuXDpcyu7SHxgJDwC6FWkHcQVR4sOK@mail.gmail.com>
<1282164833.27661.5.camel@vanquo.pezone.net>
<AANLkTinOpZ5MFd91becwrhrC1fcW3GdKUJaUszh0yGY-@mail.gmail.com>
<4C7525670200002500034BC1@gw.wicourts.gov>
<AANLkTimDi72ry2YH=URABA6n=n-eO8nGpf4pxUEcRH38@mail.gmail.com>
<4C7662FB0200002500034C51@gw.wicourts.gov>
<AANLkTinYzETTMAEJh3RqWVVenKyM0ftCCsU+AOtTRsN1@mail.gmail.com>
<4C7677520200002500034C80@gw.wicourts.gov>
<AANLkTinUvsadhOhoRAU2v0S54Y0OFTW2yCsyBMuV9JKC@mail.gmail.com>
Thom Brown <thom@linux.com> wrote:
> Yeah, I think that covers it well. :)
I found a typo. :-( Another revision attached.
-Kevin
Attachments:constraint-indexes-3.patch (text/plain, 2.1K) download
*** a/doc/src/sgml/ddl.sgml
--- b/doc/src/sgml/ddl.sgml
***************
*** 550,555 **** CREATE TABLE products (
--- 550,560 ----
</indexterm>
<para>
+ Adding a unique constraint will automatically create a unique btree+ index on the column or group of columns declared for the constraint.+ </para>+ + <para>
In general, a unique constraint is violated when there is more than
one row in the table where the values of all of the
columns included in the constraint are equal.
***************
*** 623,628 **** CREATE TABLE example (
--- 628,638 ----
</para>
<para>
+ Adding a primary key will automatically create a unique btree index+ on the column or group of columns declared for the primary key.+ </para>+ + <para>
A table can have at most one primary key. (There can be any number
of unique and not-null constraints, which are functionally the same
thing, but only one can be identified as the primary key.)
***************
*** 832,837 **** CREATE TABLE order_items (
--- 842,857 ----
</para>
<para>
+ Since a <command>DELETE</command> of a row from a referenced table+ or an <command>UPDATE</command> of a referenced column will require+ a scan of the referencing table for rows matching the old value, it+ is often a good idea to index the referencing columns. Because it+ is not always needed, and there are many choices available on how+ to index, declaration of a foreign key constraint does not+ automatically create an index.+ </para>+ + <para>
More information about updating and deleting data is in <xref
linkend="dml">.
</para>
***************
*** 875,880 **** CREATE TABLE circles (
--- 895,905 ----
See also <link linkend="SQL-CREATETABLE-EXCLUDE"><command>CREATE
TABLE ... CONSTRAINT ... EXCLUDE</></link> for details.
</para>
+ + <para>+ Adding an exclusion constraint will automatically create an index+ of the type specified in the constraint declaration.+ </para>
</sect2>
</sect1>
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-docs@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, thom@linux.com, peter_e@gmx.net
Subject: Re: Primary Key index
In-Reply-To: <4C7684BE0200002500034CDC@gw.wicourts.gov>
References: <AANLkTi=zsckLwmTuXDpcyu7SHxgJDwC6FWkHcQVR4sOK@mail.gmail.com> <1282164833.27661.5.camel@vanquo.pezone.net> <AANLkTinOpZ5MFd91becwrhrC1fcW3GdKUJaUszh0yGY-@mail.gmail.com> <4C7525670200002500034BC1@gw.wicourts.gov> <AANLkTimDi72ry2YH=URABA6n=n-eO8nGpf4pxUEcRH38@mail.gmail.com> <4C7662FB0200002500034C51@gw.wicourts.gov> <AANLkTinYzETTMAEJh3RqWVVenKyM0ftCCsU+AOtTRsN1@mail.gmail.com> <4C7677520200002500034C80@gw.wicourts.gov> <AANLkTinUvsadhOhoRAU2v0S54Y0OFTW2yCsyBMuV9JKC@mail.gmail.com> <4C7684BE0200002500034CDC@gw.wicourts.gov>
* 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