Sample Header Ad - 728x90

Moving records between tables in CockroachDB is taking too long

1 vote
1 answer
153 views
I have a requirement where I have to move records from table original_table to table new_table for the last N days. Below is a small sample of my basic script that does this.
while True:

    result = INSERT INTO new_table (SELECT * FROM original_table WHERE (crdb_internal_expiration > (current_timestamp() + INTERVAL 'X days')) ORDER BY (unique_id) DESC LIMIT batch_limit OFFSET starting_point);

    if result.rowcount  last_processed_id
ORDER BY id DESC
LIMIT 100;
cockroachdb version is at 23
Asked by Brunaldo (23 rep)
Feb 14, 2024, 07:45 PM
Last activity: Feb 14, 2024, 08:06 PM