Managing partitions

In this recipe, we are going to show how the partitioning scheme remains intact when an existing partition is dropped or a new partition is added.

Getting ready

Refer to the first recipe, Implementing partitioning, before reading the steps outlined in this recipe.

How to do it...

There are two scenarios here. One is what happens when an existing partition is deleted and the other is what happens when a new partition is added. Let's discuss both cases:

  1. In the first scenario we will drop an existing partition table. Here it is the country_code_sa table that will be dropped:

    Before dropping the country_log_sa child table, first see the records in the country_log master table:

             postgres=# SELECT * from country_log;          created_at ...

Get PostgreSQL High Performance Cookbook 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.