# Check data distribution between storage devices in Managed ClickHouse®'s tiered storage


Monitor how your data is distributed between the two layers of your tiered storage: Network-attached block storage and object storage.

If you have the tiered storage feature
[enabled](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/), your
data in Managed ClickHouse is
distributed between two storage devices (tiers). You can check on what
storage devices your databases and tables are stored. You can also
preview their total sizes as well as part counts, minimum part sizes,
median part sizes, and maximum part sizes.

## Prerequisites

-   Tiered storage
    [enabled](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/)
-   Command line tool
    ([ClickHouse client](/product/dbaas/service-specific/clickhouse/how-to/connect-with-clickhouse-cli/))
    installed

## Run a data distribution check with the ClickHouse client

1.  [Connect to your Managed ClickHouse service](/product/dbaas/service-specific/clickhouse/how-to/list-connect-to-service/)
    using, for example, the ClickHouse client.

1.  Run the following query:

    ```sql
    SELECT
        database,
        table,
        disk_name,
        formatReadableSize(sum(data_compressed_bytes)) AS total_size,
        count(*) AS parts_count,
        formatReadableSize(min(data_compressed_bytes)) AS min_part_size,
        formatReadableSize(median(data_compressed_bytes)) AS median_part_size,
        formatReadableSize(max(data_compressed_bytes)) AS max_part_size
    FROM system.parts
    GROUP BY
        database,
        table,
        disk_name
    ORDER BY
        database ASC,
        table ASC,
        disk_name ASC
    ```

    You can expect output similar to the following, here for the `trips` table from the
    [quick start](/product/dbaas/service-specific/clickhouse/quick-start/) with its oldest
    partitions moved to object storage:

    ```text
    ┌─database─┬─table─┬─disk_name─┬─total_size─┬─parts_count─┬─min_part_size─┬─median_part_size─┬─max_part_size─┐
    │ default  │ trips │ default   │ 39.52 MiB  │           2 │ 18.09 MiB     │ 19.76 MiB        │ 21.43 MiB     │
    │ default  │ trips │ remote    │ 117.53 MiB │           3 │ 30.29 MiB     │ 40.29 MiB        │ 46.94 MiB     │
    └──────────┴───────┴───────────┴────────────┴─────────────┴───────────────┴──────────────────┴───────────────┘
    ```

The query returns a table with data distribution details for all
databases and tables that belong to your service: the storage device
they use, their total sizes as well as parts counts and sizing.

## What's next

-   [Transfer data between network-attached block storage and object storage](/product/dbaas/service-specific/clickhouse/how-to/transfer-data-tiered-storage/)
-   [Configure data retention thresholds for tiered storage](/product/dbaas/service-specific/clickhouse/how-to/configure-tiered-storage/)

-   [About tiered storage in Managed ClickHouse](/product/dbaas/service-specific/clickhouse/overview/clickhouse-tiered-storage/)
-   [Enable tiered storage in Managed ClickHouse](/product/dbaas/service-specific/clickhouse/how-to/enable-tiered-storage/)

