I have table which is contained list partition in postgres database
create table test(id int, name character varying) partition by list(id);
when I insert data, it is throwing an error.
insert into test values(1,'test1'),(2,'test2')
ERROR: Partition key of the failing row contains (id) = (1).no partition of relation "test" found for row
Note: as now I cannot predefine what are the id's can insert
Based on the id's inserted on table, postgres tables needs to partitioned automatically
1 Answer 1
PostgreSQL will not create partition tables automatically for you, this is something you need to either create ahead of time, or create new partitions when the need arises.
Please refer to the step-by-step example: https://www.postgresql.org/docs/current/ddl-partitioning.html#DDL-PARTITIONING-DECLARATIVE-EXAMPLE
2 Comments
Explore related questions
See similar questions with these tags.
id inttells me that the maximum number for the id will be 2147483647. How many records do you expect and how many partitions do you want? Pick an answer and create your partitions.