Exploring declarative partitioning
In this section, we will talk about declarative partitioning. It has been available in PostgreSQL since version 10, but its performance has increased in newer versions. We will now look at an example of partitioning by range and an example of partitioning by list.
List partitioning
In the first example of declarative partitioning, we will use the same example that we looked at when we introduced partitioning using inheritance. We will see that things become much simpler using the declarative partitioning method:
- Now let’s create our parent table:
forumdb=> CREATE TABLE part_tags ( pk SERIAL NOT NULL , level INTEGER NOT NULL DEFAULT 0, tag VARCHAR (255) NOT NULL, primary key (pk,level) ) PARTITION BY LIST (level);
As we can see from the preceding example, we have to define what kind of partitioning we want to apply. In this case, it is
LIST PARTITIONING
. Another important thing to note is that the...