Re: Need guidance on partioning

Поиск
Список
Период
Сортировка
От Ron Johnson
Тема Re: Need guidance on partioning
Дата
Msg-id CANzqJaA7DruVV_6aeX+B0igQgWUBJ04+ZZyLsz6JZzn8HF7ALg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Need guidance on partioning  (Muhammad Salahuddin Manzoor <salahuddin.m@bitnine.net>)
Список pgsql-admin
On Wed, May 22, 2024 at 8:50 AM Muhammad Salahuddin Manzoor <salahuddin.m@bitnine.net> wrote:
Dear Srinivasan,

Implementing partitioning in PostgreSQL can significantly improve the performance of your database

1. Deleting Records Older Than 18 Months

Create the Parent Table: Define your main table as partitioned by range on the timestamp column.

CREATE TABLE your_table (
    id SERIAL PRIMARY KEY,
    timestamp TIMESTAMPTZ NOT NULL,
    account_id INT,
    user_id INT,
    -- other columns
) PARTITION BY RANGE (timestamp);


That's invalid syntax (as of PG 15):

psql (15.7)
Type "help" for help.

dba=#
dba=# CREATE TABLE your_table (
dba(#     id SERIAL PRIMARY KEY,
dba(#     timestamp TIMESTAMPTZ NOT NULL,
dba(#     account_id INT,
dba(#     user_id INT
dba(# ) PARTITION BY RANGE (timestamp);
ERROR:  unique constraint on partitioned table must include all partitioning columns
DETAIL:  PRIMARY KEY constraint on table "your_table" lacks column "timestamp" which is part of the partition key.


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

Предыдущее
От: M Sarwar
Дата:
Сообщение: Re: Need guidance on partioning
Следующее
От: Rui DeSousa
Дата:
Сообщение: Re: Need guidance on partioning