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.
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 policy | Where data is stored | Best for | Cost |
|---|---|---|---|
| Hot storage | All data on SSDs | Tables queried frequently with strict latency requirements | Highest |
| Cold storage | All data in OSS (zone-redundant storage, ZRS) | Archival data rarely or never accessed | Lowest |
| Mixed storage | Hot partitions on SSDs, cold partitions in OSS | Large time-partitioned tables where recent data is active and older data is rarely queried | Medium |
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.
When you change the hot partition count
Increase from N to M (M > N):
M - Ncold partitions (those with the largest key values) are promoted to hot.Decrease from N to M (M < N):
N - Mhot 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.
Example — decrease from 5 to 4: Partition 20241221 (smallest hot partition key) moves from hot to cold.
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
| Parameter | Description |
|---|---|
table_schema | Database name |
table_name | Table name |
storage_policy | Storage policy: HOT, COLD, or MIXED |
hot_partition_count | Number of hot partitions (after shards are unioned; may exceed the configured value—see note below) |
cold_partition_count | Number of cold partitions |
rt_total_size | Total size of real-time data (rt_data_size + rt_index_size). Unit: bytes |
rt_data_size | Size of real-time data. Unit: bytes |
rt_index_size | Size of primary key and index data in real-time data. Unit: bytes |
hot_total_size | Total size of data in hot partitions (hot_data_size + hot_index_size). Unit: bytes |
hot_data_size | Size of data in hot partitions. Unit: bytes |
hot_index_size | Size of primary key and index data in hot partitions. Unit: bytes |
cold_total_size | Total size of data in cold partitions (cold_data_size + cold_index_size). Unit: bytes |
cold_data_size | Size of data in cold partitions. Unit: bytes |
cold_index_size | Size 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_sizeandcold_total_sizeare both 0 after writing data, the data is synchronized in real time.rt_total_sizereflects the current size. Run a BUILD statement to convert real-time data to historical data, after whichhot_total_sizeandcold_total_sizeare populated.The configured
hot_partition_countspecifies the number of hot partitions per shard. The queriedhot_partition_countis 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.
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
| Parameter | Description |
|---|---|
table_schema | Database name |
table_name | Table name |
task_id | ID of the storage policy change job |
source_storage_policy | Original storage policy: HOT, COLD, or MIXED |
source_hot_partition_count | Number of hot partitions before the change |
dest_storage_policy | New storage policy: HOT, COLD, or MIXED |
dest_hot_partition_count | Number of hot partitions after the change |
hot_to_cold_partition_count | Number of partitions moved from hot to cold |
cold_to_hot_partition_count | Number of partitions moved from cold to hot |
hot_to_cold_data_size | Size of data moved from hot to cold. Unit: bytes |
cold_to_hot_data_size | Size of data moved from cold to hot. Unit: bytes |
hot_data_size_before_change | Hot data size before the change. Unit: bytes |
cold_data_size_before_change | Cold data size before the change. Unit: bytes |
hot_data_size_after_change | Hot data size after the change. Unit: bytes |
cold_data_size_after_change | Cold data size after the change. Unit: bytes |
start_time | Start of the time range within which the storage policy is changed |
update_time | End of the time range within which the storage policy is changed |
progress | Change progress. Unit: % |
status | Change status: INIT (not started), RUNNING (in progress), or FINISH (complete) |