[Solved] QuestDB Exception–ERROR: Cannot insert rows out of order.

I am trying to migrate the data and insert the history into QuestDB. I create the table as

create table records(
type INT,
interval INT,
timestamp TIMESTAMP,
name STRING) timestamp(timestamp)

And inserts data through JDBC.

1. Question details

I received the error “cannot insert rows out of order”. I read that QuestDB supports are out of order, but somehow I can’t make it work.

Caused by: org.postgresql.util.PSQLException: ERROR: Cannot insert rows out of order. Table=/root/.questdb/db/dwd_robot_running_data
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2674)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2364)
	... 19 more

2. Cause of problem

You can only insert rows in the partitioned table out of order, create a new partitioned table and copy the data into it

3. Solution

Adding partitions during table creation

create table records2(
 type INT,
 interval INT,
 timestamp TIMESTAMP,
 name STRING
timestamp(timestamp) partition by DAY

insert into records2
select * from records

drop table records

rename table records2 to records

After that, you can insert out of order into the table records

Read More: