Re: different sort order for primary key index - Mailing list pgsql-general

From Tom Lane
Subject Re: different sort order for primary key index
Date
Msg-id 12902.1255530596@sss.pgh.pa.us
Whole thread Raw
In response to different sort order for primary key index  (Paul Hartley <phartley@gmail.com>)
Responses Re: different sort order for primary key index
List pgsql-general
Paul Hartley <phartley@gmail.com> writes:
> ... I'm unclear
> if PostgreSQL treats primary keys differently from unique, non-null
> constraints.

The *only* thing that the system does specially with a primary key
constraint is that a PK creates a default column target for foreign key
references.  For example,

create table m (id int primary key);
create table s (refid int references m);

versus

create table m (id int);
create unique index mi on m (id);
create table s (refid int references m(id));

I have to spell out "(id)" in that last command because there's no PK
to establish a default target.

Other than that, behavior and performance should be the same.  The
planner and executor only care about the indexes, not about whatever
constraints they might have come from.  Likewise, NOT NULL is NOT NULL
regardless of what syntax you used to slap it onto the column.

            regards, tom lane

pgsql-general by date:

Previous
From: "Chase, John"
Date:
Subject: Re: COPY BINARY 8.3 to 8.4 timestamp incorrect
Next
From: Sam Mason
Date:
Subject: Re: different sort order for primary key index