Re: tricky CHECK condition

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: tricky CHECK condition
Дата
Msg-id 422.959058699@sss.pgh.pa.us
обсуждение исходный текст
Ответ на tricky CHECK condition  (Arcady Genkin <a.genkin@utoronto.ca>)
Список pgsql-general
Arcady Genkin <a.genkin@utoronto.ca> writes:
> I want to check values of `track_number' to be unique for the
> disk.

Not sure if it can be done with a CHECK condition, but the traditional
solution is to create a unique index on the two columns:

create unique index tracks_disk_track_i on tracks(disk_id, track_number);

Updating an index should be a lot faster than running a whole subquery
for each insert, and the planner may be able to use the index to speed
up other queries too.  So, it's a win all round...

            regards, tom lane

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

Предыдущее
От: Arcady Genkin
Дата:
Сообщение: Re: tricky CHECK condition
Следующее
От: "Janet"
Дата:
Сообщение: