I have a table that is partitioned by date on a monthly basis beginning January 1, 2014. There is significantly more rows of data in 2015 than there were in 2014 and the data in 2014 is not accessed frequently, so I am considering merging the rows from 2014 into a single partition. My assumption is that this will improve the query optimizer and help prevent too many partitions from being created over time. The steps I was planning to do that are:
- Create a new partition called xyz_2014
- Copy the data from 2014 into xyz_2014
- Alter table xyz_2014 to inherit from xyz
- Alter old tables xyz_2014_01, xyz_2014_02, etc. to not inherit from xyz
- Update my INSERT trigger for xyz to reference xyz_2014
- Confirm that everything is working correctly
- Delete old tables
Is this approach typically how merging tables in Postgres is done?