Transfer data between storage devices in Aiven for ClickHouse®'s tiered storage
Moving data from SSD to object storage allows you to size down your SSD by selecting a service plan with less SSD capacity. You can move the data back to your SSD anytime.
You can transfer data between storage devices in Aiven for ClickHouse® using SQL statements against your tables directly.
Prerequisites
- At least one Aiven for ClickHouse service
- Command line tool (ClickHouse client) installed
Transfer data from SSD to object storage
- Automatic data transfer
- Manual data transfer
If you enable the tiered storage feature on your table, by default your data is moved from SSD to object storage as soon as the SSD reaches 80% of its capacity.
-
Connect to your Aiven for ClickHouse service using, for example, the ClickHouse client.
-
Run the following query:
ALTER TABLE database-name.tablename MODIFY SETTING storage_policy = 'tiered'
Now, with the tiered storage feature enabled, your data is moved from SSD to object storage when the SSD reaches 80% of its capacity.
You can also configure your tiered storage so that data is moved to object storage at a specific time.
To move data manually from SSD to object storage, run
ALTER TABLE table_name MOVE PARTITION partition_expr TO VOLUME 'remote'
To configure data retention thresholds to automatically move data from SSD to object storage, see Configure data retention thresholds in Aiven for ClickHouse®'s tiered storage.
Transfer data from object storage to SSD
Use the MOVE PARTITION|PART statement to transfer data to your SSD.
-
Connect to your Aiven for ClickHouse service using, for example, the ClickHouse client.
-
Select a database for operations you intend to perform.
USE database-name
-
Run the following query:
ALTER TABLE table_name MOVE PARTITION partition_expr TO VOLUME 'default'
Your data has been moved to the SSD.
What's next
- Check data distribution between SSD and object storage
- Configure data retention thresholds for tiered storage