Copy database and reduce database partitions

Hey, I’m looking for a way to reduce the database partitions on the new cluster, there seems to be no option for that.
I thought about manually copying tables from the database with many partitions to a new database with less partitions, but I might not have enough space / memory to do that operation.

any suggestions?


Hi Yarden!:wave:

Happy to help. The best method for this is to create a new database with required partition count, redefine tables, and move data to new tables:

  2. Create new tables in <new_db>
  3. INSERT into <new_db.table> SELECT * FROM <old_db.table> for each table

Please let us know how this works for you and if this forum entry can be marked as resolved. Thanks :pray:

Hey Maria, thank you for your help!
unfortunately this wouldn’t work as we don’t have enough space in the cluster to hold both databases at the same time (memory could also be a problem here for a single insert operation each time)

an alternative would be to divide inserts into many insert commands, and after each one, delete from the origin database the data that was inserted to the new one. that way there won’t be an out of memory issue nor a space issue.

1 Like