Re: Partitioning on the date part of a timestamp & PK issues

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Partitioning on the date part of a timestamp & PK issues
Дата
Msg-id CAKFQuwapgPw3SJf2Mk1ePbCELOyG4enXatfVx0hz_SAfu0=tog@mail.gmail.com
обсуждение исходный текст
Ответ на Partitioning on the date part of a timestamp & PK issues  (Wells Oliver <wells.oliver@gmail.com>)
Список pgsql-admin
On Thu, Jul 15, 2021 at 1:10 PM Wells Oliver <wells.oliver@gmail.com> wrote:

    primary key (guid, tid, seq)
) partition by range (extract(date from ts));

The PK is the PK, so I'm not sure what options I have there.

You are indirectly hitting the documented limitation that:

"Unique constraints (and hence primary keys) on partitioned tables must include all the partition key columns. This limitation exists because the individual indexes making up the constraint can only directly enforce uniqueness within their own partitions; therefore, the partition structure itself must guarantee that there are not duplicates in different partitions."


So if you want to enforce PKs here you need to both add the physical column to the table AND add the same to your primary key.

David J.

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

Предыдущее
От: Holger Jakobs
Дата:
Сообщение: Re: Partitioning on the date part of a timestamp & PK issues
Следующее
От: Ron
Дата:
Сообщение: Re: Partitioning on the date part of a timestamp & PK issues