Skip site navigation (1) Skip section navigation (2)

Re: Difference between UNIQUE constraint vs index

From: "John Jawed" <johnjawed(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Difference between UNIQUE constraint vs index
Date: 2007-02-28 17:25:03
Message-ID: (view raw or whole thread)
Lists: pgsql-general

AFAICS, Oracle as well.


On 2/28/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Jim C. Nasby" <jim(at)nasby(dot)net> writes:
> > In some databases if you know that an index just happens to be unique
> > you might gain some query performance by defining the index as unique,
> > but I don't think the PostgreSQL planner is that smart.
> Actually, the planner only pays attention to whether indexes are unique;
> the notion of a unique constraint is outside its bounds.  In PG a unique
> constraint is implemented by creating a unique index, and so there is
> really not any interesting difference.
> I would imagine that other DBMSes also enforce uniqueness by means of
> indexes, because it'd be awful darn expensive to enforce the constraint
> without one; but I'm only guessing here, not having looked.  Can anyone
> point to a real system that enforces unique constraints without an
> underlying index?
>                         regards, tom lane

In response to

pgsql-general by date

Next:From: Merlin MoncureDate: 2007-02-28 17:53:25
Subject: Re: SQL names for C constants
Previous:From: Tom LaneDate: 2007-02-28 17:22:58
Subject: Re: How often do I need to reindex tables?

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group