All Products
Search
Document Center

AnalyticDB:Tiered storage of hot and cold data

Last Updated:Mar 28, 2026

AnalyticDB for MySQL lets you store hot and cold partitions on separate storage media—SSDs for hot data and Object Storage Service (OSS) for cold data—so you get fast query performance where it matters while keeping storage costs low.

Important

Tiered storage applies only to tables partitioned by date or time. The cluster must run minor version 3.1.3.3 or later and be one of the following editions: Enterprise Edition, Basic Edition, Data Lakehouse Edition, or Data Warehouse Edition Elastic mode. To check or update the minor version, log in to the AnalyticDB for MySQL console and go to the Configuration Information section on the Cluster Information page.

Choose a storage policy

AnalyticDB for MySQL offers three storage policies. Use this table to select the right one for your workload:

Storage policyWhere data is storedBest forCost
Hot storageAll data on SSDsTables queried frequently with strict latency requirementsHighest
Cold storageAll data in OSS (zone-redundant storage, ZRS)Archival data rarely or never accessedLowest
Mixed storageHot partitions on SSDs, cold partitions in OSSLarge time-partitioned tables where recent data is active and older data is rarely queriedMedium

Choosing between policies:

  • Use hot storage when query latency is critical and you access most of the data regularly.

  • Use cold storage for data you archive and almost never query.

  • Use mixed storage for time-series workloads such as log tables, order history, and monitoring data—the most common choice for large partitioned tables.

How mixed storage works

When you choose mixed storage, you specify the number of hot partitions (N). AnalyticDB for MySQL sorts all partitions by partition key value in descending order: the top N partitions are hot partitions stored on SSDs, and the rest are cold partitions stored in OSS.

When partitions are added or the hot partition count changes, the system automatically re-sorts and migrates data to maintain the correct distribution. For details, see Impact of partition count changes.

Set a storage policy

At table creation

Specify the policy using the storage_policy parameter in your CREATE TABLE statement:

CREATE TABLE your_table (
    ...
)
PARTITION BY ...
PROPERTIES (
    "storage_policy" = "MIXED",   -- HOT, COLD, or MIXED
    "hot_partition_count" = "5"   -- Required when storage_policy = MIXED
);

For an existing table

Use ALTER TABLE to change the storage policy. After running this statement, you can track migration progress—see Query the storage policy change progress.

-- Switch to mixed storage with 5 hot partitions
ALTER TABLE your_table
SET PROPERTIES (
    "storage_policy" = "MIXED",
    "hot_partition_count" = "5"
);

For the full syntax reference, see CREATE TABLE and ALTER TABLE.

Billing

Hot and cold data storage is charged on a pay-as-you-go basis. For pricing details, see Pricing.

Use storage plans to offset storage costs.

Impact of partition count changes

When a new partition is inserted

All partitions are re-sorted to keep exactly N hot partitions. The partition with the smallest key value is demoted from hot to cold.

Example: hot_partition_count is 5. A new partition 20241226 (the largest key value) is inserted. After a BUILD job, the system promotes 20241226 to hot and moves 20241221 (the previous smallest hot partition) to cold.

image

When you change the hot partition count

  • Increase from N to M (M > N): M - N cold partitions (those with the largest key values) are promoted to hot.

  • Decrease from N to M (M < N): N - M hot partitions (those with the smallest key values) are demoted to cold.

Example — increase from 5 to 6: Partition 20241220 (largest cold partition key) moves from cold to hot.

image

Example — decrease from 5 to 4: Partition 20241221 (smallest hot partition key) moves from hot to cold.

image

Query the storage policy

Query for all tables

SELECT * FROM information_schema.table_usage;

Query for a specific table

SELECT * FROM information_schema.table_usage
WHERE table_schema = '<schema_name>' AND table_name = '<table_name>';

Response parameters

ParameterDescription
table_schemaDatabase name
table_nameTable name
storage_policyStorage policy: HOT, COLD, or MIXED
hot_partition_countNumber of hot partitions (after shards are unioned; may exceed the configured value—see note below)
cold_partition_countNumber of cold partitions
rt_total_sizeTotal size of real-time data (rt_data_size + rt_index_size). Unit: bytes
rt_data_sizeSize of real-time data. Unit: bytes
rt_index_sizeSize of primary key and index data in real-time data. Unit: bytes
hot_total_sizeTotal size of data in hot partitions (hot_data_size + hot_index_size). Unit: bytes
hot_data_sizeSize of data in hot partitions. Unit: bytes
hot_index_sizeSize of primary key and index data in hot partitions. Unit: bytes
cold_total_sizeTotal size of data in cold partitions (cold_data_size + cold_index_size). Unit: bytes
cold_data_sizeSize of data in cold partitions. Unit: bytes
cold_index_sizeSize of primary key and index data in cold partitions. Unit: bytes

Usage notes:

  • All size values (rt_*, hot_*, cold_*) change as INSERT, UPDATE, DELETE, and BUILD operations run.

  • If hot_total_size and cold_total_size are both 0 after writing data, the data is synchronized in real time. rt_total_size reflects the current size. Run a BUILD statement to convert real-time data to historical data, after which hot_total_size and cold_total_size are populated.

  • The configured hot_partition_count specifies the number of hot partitions per shard. The queried hot_partition_count is the union across all shards and may be larger if partition distribution differs between shards.

Example — queried `hot_partition_count` vs. configured value:

Table A has two shards and hot_partition_count is configured as 2.

  • Shard 1: P4, P5 are hot; P1, P2, P3 are cold.

  • Shard 2: P3, P4 are hot; P1, P2 are cold.

The queried value is the union: {P4, P5} ∪ {P3, P4} = {P3, P4, P5}, so hot_partition_count returns 3.

image

Query the storage policy change progress

After running ALTER TABLE to change a storage policy, track migration progress from information_schema.storage_policy_modify_progress.

Query for all tables

SELECT * FROM information_schema.storage_policy_modify_progress;

Query for a specific table

SELECT * FROM information_schema.storage_policy_modify_progress
WHERE table_schema = '<schema_name>' AND table_name = '<table_name>';

Response parameters

ParameterDescription
table_schemaDatabase name
table_nameTable name
task_idID of the storage policy change job
source_storage_policyOriginal storage policy: HOT, COLD, or MIXED
source_hot_partition_countNumber of hot partitions before the change
dest_storage_policyNew storage policy: HOT, COLD, or MIXED
dest_hot_partition_countNumber of hot partitions after the change
hot_to_cold_partition_countNumber of partitions moved from hot to cold
cold_to_hot_partition_countNumber of partitions moved from cold to hot
hot_to_cold_data_sizeSize of data moved from hot to cold. Unit: bytes
cold_to_hot_data_sizeSize of data moved from cold to hot. Unit: bytes
hot_data_size_before_changeHot data size before the change. Unit: bytes
cold_data_size_before_changeCold data size before the change. Unit: bytes
hot_data_size_after_changeHot data size after the change. Unit: bytes
cold_data_size_after_changeCold data size after the change. Unit: bytes
start_timeStart of the time range within which the storage policy is changed
update_timeEnd of the time range within which the storage policy is changed
progressChange progress. Unit: %
statusChange status: INIT (not started), RUNNING (in progress), or FINISH (complete)