Getting specific partition from the partition name

From: veem v <veema0000(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Getting specific partition from the partition name
Date: 2024-08-08 19:52:36
Message-ID: CAB+=1TUgzD7CfGbgiBAgcuttN06X11787WvJSeCPs=ek5qCgxw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi ,
We are using postgres version 15.4. We have a range partition table and the
partition naming convention is generated by pg_partman and is something
like "table_name>_pYYYY_MM_DD".

We have a requirement of extracting specific partitions ordered by the date
criteria and also do some operations on that specific date. But I am
struggling and it's not working as expected.I tried something as below but
it's not working.Can somebody guide me here please.

to_date( substring('table_part_p2024_08_08' from
'_p(\d{4})_(\d{2})_(\d{2})'), 'YYYY_MM_DD'
) < current_date

or is there any ready-made data dictionary which will give us the order of
the partitions by the date and we can get hold of the specific nth
partition in that table?

Regards
Veem

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Sabino Mullane 2024-08-08 20:35:32 Re: Column type modification in big tables
Previous Message Adrian Klaver 2024-08-08 19:01:02 Re: Destination Table - Condition Amount 0