Re: Need guidance on partioning

From: Kashif Zeeshan <kashi(dot)zeeshan(at)gmail(dot)com>
To: srinivasan s <srinioracledba7(at)gmail(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Need guidance on partioning
Date: 2024-05-22 12:19:31
Message-ID: CAAPsdheF-7x6Pj8akpDOqWL8Fm8uRgUbGadmDSRddmNi+eUm6A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi Srinivasan

You can use the following documentation to learn of PG Table Partitioning.

https://www.postgresql.org/docs/current/ddl-partitioning.html

On Wed, May 22, 2024 at 5:04 PM srinivasan s <srinioracledba7(at)gmail(dot)com>
wrote:

> Hello everyone,
>
> I hope you are all doing well.
>
> I am seeking guidance on how to implement partitioning in PostgreSQL.
>
> We have a large table that currently does not have any partitioning, and
> we have two requirements for removing old data from this table. We are
> looking to create a new table with partitioning.
>
> 1. The first requirement is to delete all records from the table that are
> older than 18 months. I believe we can achieve this by using range
> partitioning on the timestamp column.
>
RANGE Partition is a good option here.

>
> 2. The second requirement is to remove data from the table when a user
> leaves the organization. We have the account ID and user ID in the same
> table.
>
> Could someone please offer guidance on selecting the appropriate
> partitioning method (range, sub-partition, or composite)?
>
It all depends on your data structure, please go through the documentation
and then analyze your table/data structure to find the appropriate method.

>
> Additionally, not all queries use the timestamp column in the WHERE
> condition. Is it mandatory to use the partition key in the WHERE condition
> to benefit from partitioning? Can we create a composite index that combines
> the partition key column with other columns used in the WHERE clause? Would
> this be beneficial?
>
Following is the limitaiton
To create a unique or primary key constraint on a partitioned table, the
partition keys must not include any expressions or function calls and the
constraint's columns must include all of 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.

>
> Thank you.
>
>
>
>
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message srinivasan s 2024-05-22 12:21:49 Re: Need guidance on partioning
Previous Message Erik Wienhold 2024-05-22 12:13:18 Re: displaying line breaks / increasing row height in pgadmin