Re: Need guidance on partioning

From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
To: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Need guidance on partioning
Date: 2024-05-22 16:25:40
Message-ID: CANzqJaA7DruVV_6aeX+B0igQgWUBJ04+ZZyLsz6JZzn8HF7ALg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Rui DeSousa 2024-05-22 17:58:46 Re: Need guidance on partioning
Previous Message M Sarwar 2024-05-22 15:10:11 Re: Need guidance on partioning