pg_partman icon indicating copy to clipboard operation
pg_partman copied to clipboard

Range-Hash Subpartioning support in pg_partman

Open hrawulwa opened this issue 5 months ago • 6 comments

We have use cases that require us to create Range-Hash Partitioned tables. I'm assuming pg_partman supports this, as I have seen create_subparent function in the documentation. I'm looking for example how to create Partitioned table by Range, and then sub-partition by Hash, using pg_partman.

Here is an example of the table DDL. create table sales( id serial, sale_date DATE, amount NUMERIC) partition by range(sale_date); alter table sales add primary key(id, sale_date);

create table sales_2024 partition of sales for values from ('2024-01-01') to ('2024-09-01') partition by hash(id); create table sales_2024_1 partition of sales_2024 for values with(modulus 4, remainder 0); create table sales_2024_2 partition of sales_2024 for values with(modulus 4, remainder 1); create table sales_2024_3 partition of sales_2024 for values with(modulus 4, remainder 2); create table sales_2024_4 partition of sales_2024 for values with(modulus 4, remainder 3);

I would also like to know if the Partition maintenance function "run_maintenance()" will automatically take care of sub-partition allocation and de-allocation.

Thanks Hari

hrawulwa avatar Aug 29 '24 17:08 hrawulwa