Re: Need guidance on partioning - Mailing list pgsql-admin

From Ron Johnson
Subject Re: Need guidance on partioning
Date
Msg-id CANzqJaA7DruVV_6aeX+B0igQgWUBJ04+ZZyLsz6JZzn8HF7ALg@mail.gmail.com
Whole thread Raw
In response to Re: Need guidance on partioning  (Muhammad Salahuddin Manzoor <salahuddin.m@bitnine.net>)
List 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 by date:

Previous
From: M Sarwar
Date:
Subject: Re: Need guidance on partioning
Next
From: Rui DeSousa
Date:
Subject: Re: Need guidance on partioning