How to partition postgres table using intermediate table

后端 未结 2 770
一向
一向 2020-12-12 05:41

I am using postgres 10 db.

I am having Customers table consisting of following columns

custid (primary key),
name,
phonenumber,
email,
dateofbirth,
a         


        
相关标签:
2条回答
  • 2020-12-12 06:33

    Try this method:

    1. First of all, create an additional column in customer table as you want to logical partition.
    2. Then update that columns using customer and intermediate table
    3. After updating truncate your table

    For each month you can run this script and this will give you logical partitioning.

    update customer set partition_column=to_char(Join_Date, 'YYYY-MM')
    join intermediate_table on intermediate_table.custid=customer.custid
    and  intermediate_table.Join_Date=customer.Join_Date
    
    truncate table intermediate_table
    
    0 讨论(0)
  • 2020-12-12 06:39

    There is an example for your problem in the Postgres documentation.

    PostgreSQL: Documentation: 10: 5.10. Table Partitioning

    0 讨论(0)
提交回复
热议问题