Re: Need guidance on partioning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 22, 2024 at 8:50 AM Muhammad Salahuddin Manzoor <salahuddin.m@xxxxxxxxxxx> 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.



[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux