# Tiered storage in Managed ClickHouse®


The tiered storage feature introduces a method of organizing and storing data in two tiers for improved efficiency and cost optimization. The data is automatically moved to an appropriate tier based on your database's disk usage.

On top of this default data allocation mechanism, you can control the tier your
data is stored in using custom data retention periods.

## Tiered storage architecture

The tiered storage in Managed ClickHouse® consists of the following two
layers:

- Network-attached block storage (cloud provider-managed disks) - the first tier:
  Fast storage with limited capacity, optimized for fresh and frequently
  queried data, and relatively costly compared to object storage
- Object storage - the second tier: Affordable storage with unlimited capacity, better
  suited for historical and more rarely queried data, and relatively slower.

The first tier uses Exoscale network-attached block storage, and the second tier uses
[Exoscale Object Storage](/product/storage/object-storage/) (S3-compatible), in the same European
zone as your service: tiered data never leaves Exoscale infrastructure.

Managed ClickHouse's tiered storage supports
[local on-disk cache for remote files](/product/dbaas/service-specific/clickhouse/how-to/local-cache-tiered-storage/),
which is enabled by default. You can
[disable the cache](/product/dbaas/service-specific/clickhouse/how-to/local-cache-tiered-storage/#disable-the-cache)
or
[drop it](/product/dbaas/service-specific/clickhouse/how-to/local-cache-tiered-storage/#free-up-space) to free
up the space it occupies.

## Why use it

By
[enabling](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/) and properly
[configuring](/product/dbaas/service-specific/clickhouse/how-to/configure-tiered-storage/) the tiered storage
feature in Managed ClickHouse, you can
use storage resources efficiently and, therefore, significantly reduce
storage costs of your Managed ClickHouse instance.

## How it works

After you
[enable](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/) the tiered storage feature,
Managed ClickHouse by default
stores data on network-attached block storage until it reaches 80% of its capacity.
After exceeding this
[configurable size-based threshold](/product/dbaas/service-specific/clickhouse/how-to/configure-tiered-storage/#size-based-threshold),
data is stored in object storage.

Optionally, you can
[configure the time-based threshold](/product/dbaas/service-specific/clickhouse/how-to/configure-tiered-storage/)
for your storage. Based on the time-based threshold, the
data moves from network-attached block storage to object storage after a specified time
period.

```mermaid
sequenceDiagram
        Application->>+Network-attached block storage: writing data
        Network-attached block storage->>Object storage: moving data based <br> on storage policies
        par Application to Network-attached block storage
            Application-->>Network-attached block storage: querying data
        and Application to Object storage
            Application-->>Object storage: querying data
        end
        alt if stored in Object storage
            Object storage->>Application: reading data
        else if stored in Network-attached block storage
            Network-attached block storage->>Application: reading data
        end
```

> [!NOTE]
> Exoscale backs up data that resides on network-attached block storage and in object
> storage.

## Typical use case

In your Managed ClickHouse service, a significant amount of
data sits unused for a long time and is rarely accessed. That data is stored
on network-attached block storage, which is relatively costly. You decide to
[enable](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/) tiered storage to make
your data storage more efficient and reduce the costs. For that purpose, you
[enable](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/) the feature on tables to
be optimized. You
[configure](/product/dbaas/service-specific/clickhouse/how-to/configure-tiered-storage/) the time-based
threshold to control how your data is stored between the two layers.

## Limitations {#tiered-storage-limitations}

-   When
    [enabled](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/), the tiered storage
    feature cannot be deactivated.

> [!TIP]
> As a workaround, you can create a table (without enabling tiered
> storage on it) and copy the data from the original table (with the
> tiered storage feature
> [enabled](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/)) to the new table. As
> soon as the data is copied to the
> new table, you can remove the original table.

-   With the tiered storage feature
    [enabled](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/), it's not possible to
    connect to an external existing object storage or cloud storage bucket.

-   There can be unused data in object storage, for example before Managed ClickHouse
    performs a merge of parts or when a backup is performed before your table changes.
    Such unused data is removed once a day.

## What's next

-   [Enable tiered storage in Managed ClickHouse](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/)
-   [Configure data retention thresholds for tiered storage](/product/dbaas/service-specific/clickhouse/how-to/configure-tiered-storage/)

-   [Check data volume distribution between different disks](/product/dbaas/service-specific/clickhouse/how-to/check-data-tiered-storage/)
-   [Transfer data between network-attached block storage and object storage](/product/dbaas/service-specific/clickhouse/how-to/transfer-data-tiered-storage/)

