Live migration of a partitioned table

If you executed the creation of partition, index, and TRIGGER functions in this chapter against a live dellstore2 installation, you've now got all of the actual data in the parent orders table, with a number of empty partitions. This is typically how a live migration to partitions would prefer to happen too. The other option is to dump the table, create the partition structure, and then load the data back in again, which involves some downtime.

There is another way though. Consider the UPDATE trigger again. What if you installed one of those against the parent table? You could then migrate to the partitioned structure just by updating every row. Here's what the code looks like for that:

CREATE OR REPLACE ...

Get PostgreSQL 10 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.