Skip to navigationSkip to main contentSkip to footerScaleway Docs HomepageAsk our AI
Ask our AI

Manage data storage in a Data Warehouse for ClickHouse® deployment

Scaleway Data Warehouse for ClickHouse® uses ClickHouse® native storage policies to decide where table data is stored: on Block Storage, on Object Storage, or on both. You apply a storage policy to each table when you create it.

Before you start

To complete the following actions, you must have:

Overview

You can choose from the following storage policies:

  • tiered (default in Scaleway Data Warehouse for ClickHouse®)
  • s3_cache (cache mode)
  • default (local-only mode)

The following table describes the behavior and use case of each storage policy.

Storage and policyBehaviorWhen to use
tieredWrites data to Block Storage first, then automatically moves parts to Object Storage when the disk is 90% full. You can change this threshold with the move_factor parameter.General purpose setting for fast local writes, with transparent spillover to Object Storage as the dataset grows.
s3_cacheStores data on Object Storage. A local Block Storage cache layer keeps frequently read parts to accelerate repeated reads.Large datasets that mostly live in Object Storage, with repeated reads on smaller subsets that benefit from local caching.
defaultStores data on Block Storage only.Small datasets that need the lowest read and write latency on local disk, and that fit in the Block Storage volume.

Tiered storage policy

Apply the tiered policy

tiered is the default storage policy of your deployment. ClickHouse® stores data on the hot volume (Block Storage) until the volume reaches 90% of its capacity, then moves data to the cold volume (Object Storage). The move_factor parameter controls this threshold. Its default value is 0.1. See Configure the move factor for more information.

Connect to your deployment, then run one of the following SQL queries to apply the tiered storage policy.

Configure the move factor

The move_factor parameter defines when ClickHouse® moves data from the hot volume (Block Storage) to the cold volume (Object Storage). Data moves once the free space on the hot volume drops below this fraction of its total capacity.

move_factor accepts any value between 0 and 1. The default value is 0.1, which means data moves to Object Storage when the hot volume is 90% full. For example, a value of 0.3 moves data when the hot volume is 70% full.

The move_factor parameter applies to the whole deployment, and to all tables that use the tiered storage policy. You can only set or update it with the Data Warehouse API (External link), when you create or update a deployment.

The following examples use the SCW_SECRET_KEY, SCW_DEFAULT_REGION, and SCW_PROJECT_ID environment variables. Set these variables, or replace them with the appropriate values.

Move data with the tiered policy

With the tiered storage policy, you can manually move partitions between the hot volume (Block Storage) and the cold volume (Object Storage). Run the following SQL queries:

  • Move a partition to the cold volume (Object Storage):

    ALTER TABLE tiered_table MOVE PARTITION '2024-08' TO VOLUME 'cold';
  • Move a non-partitioned table (tuple()) to the cold volume (Object Storage):

    ALTER TABLE tiered_table_without_partitions MOVE PARTITION tuple() TO VOLUME 'cold';
  • Move a partition to the hot volume (Block Storage):

    ALTER TABLE tiered_table MOVE PARTITION '2024-08' TO VOLUME 'hot';
  • Move a non-partitioned table (tuple()) to the hot volume (Block Storage):

    ALTER TABLE tiered_table_without_partitions MOVE PARTITION tuple() TO VOLUME 'hot';

S3 cache policy

Connect to your deployment, then run the following SQL query to create a table with the s3_cache storage policy.

CREATE TABLE cache_table
(
  id UInt64,
  ts DateTime,
  value Float32
)
ENGINE = MergeTree
PARTITION BY toYYYYMM(ts)
ORDER BY id
SETTINGS storage_policy = 's3_cache';

Local-only policy

Connect to your deployment, then run the following SQL query to create a table with the default (Block Storage only) storage policy.

CREATE TABLE local_table
(
  id UInt64,
  ts DateTime,
  value Float32
)
ENGINE = MergeTree
PARTITION BY toYYYYMM(ts)
ORDER BY id
SETTINGS storage_policy = 'default';
Still need help?

Create a support ticket
No Results