Sub-partitioning

PostgreSQL supports sub-partitioning. That means partitions can also be partitioned themselves.

The list-partition scheme can be used with fields that don't have too many distinct values and when the values are known in advance. We can use this scheme for the HTTP status code, and combine it with range partitioning as we did before. To create another partition for October 2018 and then further partition it for different values of the HTTP code, the following commands can be used:

CREATE TABLE dwh.access_log_2018_10 PARTITION OF dwh.access_log_partitioned FOR VALUES FROM ('2018-10-01') TO ('2018-11-01')PARTITION BY LIST (status_code);CREATE TABLE dwh.access_log_2018_10_200 PARTITION OF dwh.access_log_2018_10 FOR VALUES IN ...

Get Learning PostgreSQL 11 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.