Re: Difference between UNIQUE constraint vs index

Поиск
Список
Период
Сортировка
От Brandon Aiken
Тема Re: Difference between UNIQUE constraint vs index
Дата
Msg-id F8E84F0F56445B4CB39E019EF67DACBA48C253@exchsrvr.winemantech.com
обсуждение исходный текст
Ответ на Re: Difference between UNIQUE constraint vs index  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Difference between UNIQUE constraint vs index  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
SQLite, MySQL, and MS Access each use indexes for unique constraints.

Doesn't the SQL spec specify that CREATE INDEX can be used to create
UNIQUE indexes?  Are there any real systems that don't support indexes
but that support unique?  It seems silly, since the code for a primary
key is a superset of what's needed for unique, so I would expect only
legacy systems to support non-indexed uniques.  Any newer DBMS would
implement primary keys and then steal the code for uniques.

--
Brandon Aiken
CS/IT Systems Engineer

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Tom Lane
Sent: Wednesday, February 28, 2007 1:17 AM
To: Jim C. Nasby
Cc: John Jawed; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Difference between UNIQUE constraint vs index

"Jim C. Nasby" <jim@nasby.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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


--------------------------------------------------------------------
** LEGAL DISCLAIMER **
Statements made in this e-mail may or may not reflect the views and
opinions of Wineman Technology, Inc. or its employees.

This e-mail message and any attachments may contain legally privileged,
confidential or proprietary information. If you are not the intended
recipient(s), or the employee or agent responsible for delivery of
this message to the intended recipient(s), you are hereby notified
that any dissemination, distribution or copying of this e-mail
message is strictly prohibited. If you have received this message in
error, please immediately notify the sender and delete this e-mail
message from your computer.

В списке pgsql-general по дате отправления:

Предыдущее
От: Howard Cole
Дата:
Сообщение: Re: pgagent install on windows
Следующее
От: Shelby Cain
Дата:
Сообщение: Re: How to Kill IDLE users