How to partition postgres table using intermediate table

ぐ巨炮叔叔 提交于 2019-11-28 14:45:19

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

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

PostgreSQL: Documentation: 10: 5.10. Table Partitioning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!