Re: Primary keys and composite unique keys(basic question)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Primary keys and composite unique keys(basic question)
Дата
Msg-id 3168686.1617199973@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Primary keys and composite unique keys(basic question)  (Mohan Radhakrishnan <radhakrishnan.mohan@gmail.com>)
Ответы Re: Primary keys and composite unique keys(basic question)
Список pgsql-general
Mohan Radhakrishnan <radhakrishnan.mohan@gmail.com> writes:
>              We have UUIDs in our tables which are primary keys. But in
> some cases
> we also identify a composite unique key apart from the primary key.

> My assumption is that there should be a unique key index created by us
> using the composite key. And when we fetch using this composite key instead
> of the primary key we have a performance boost due to the index.

You haven't provided a lot of detail, but use-a-UUID-as-a-primary-key
is often an antipattern.  The UUIDs are quasi-random, meaning there's
no locality of reference in the primary key index, resulting in
inefficiency in searches and insertions.  If the composite key you
mention has some actual relationship to your application's usage
patterns, it could be winning as a result of better locality of
access to that index.

            regards, tom lane



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

Предыдущее
От: Alexey Bashtanov
Дата:
Сообщение: pg_rewind
Следующее
От: Mohan Radhakrishnan
Дата:
Сообщение: Re: Primary keys and composite unique keys(basic question)