Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4832291

Browse files
committed
Explain automatic creation (or lack of it) of indexes for the various types
of constraints.Kevin Grittner
1 parent16567b0 commit4832291

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

‎doc/src/sgml/ddl.sgml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.96 2010/08/23 02:43:25 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.97 2010/08/26 21:08:35 tgl Exp $ -->
22

33
<chapter id="ddl">
44
<title>Data Definition</title>
@@ -544,6 +544,11 @@ CREATE TABLE products (
544544
</programlisting>
545545
</para>
546546

547+
<para>
548+
Adding a unique constraint will automatically create a unique btree
549+
index on the column or group of columns used in the constraint.
550+
</para>
551+
547552
<indexterm>
548553
<primary>null value</primary>
549554
<secondary sortas="unique constraints">with unique constraints</secondary>
@@ -622,6 +627,11 @@ CREATE TABLE example (
622627
uniquely.
623628
</para>
624629

630+
<para>
631+
Adding a primary key will automatically create a unique btree index
632+
on the column or group of columns used in the primary key.
633+
</para>
634+
625635
<para>
626636
A table can have at most one primary key. (There can be any number
627637
of unique and not-null constraints, which are functionally the same
@@ -831,6 +841,16 @@ CREATE TABLE order_items (
831841
column is changed (updated). The possible actions are the same.
832842
</para>
833843

844+
<para>
845+
Since a <command>DELETE</command> of a row from the referenced table
846+
or an <command>UPDATE</command> of a referenced column will require
847+
a scan of the referencing table for rows matching the old value, it
848+
is often a good idea to index the referencing columns. Because this
849+
is not always needed, and there are many choices available on how
850+
to index, declaration of a foreign key constraint does not
851+
automatically create an index on the referencing columns.
852+
</para>
853+
834854
<para>
835855
More information about updating and deleting data is in <xref
836856
linkend="dml">.
@@ -875,6 +895,11 @@ CREATE TABLE circles (
875895
See also <link linkend="SQL-CREATETABLE-EXCLUDE"><command>CREATE
876896
TABLE ... CONSTRAINT ... EXCLUDE</></link> for details.
877897
</para>
898+
899+
<para>
900+
Adding an exclusion constraint will automatically create an index
901+
of the type specified in the constraint declaration.
902+
</para>
878903
</sect2>
879904
</sect1>
880905

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp