Policies and methods for hot and cold data storage - AnalyticDB (original) (raw)

AnalyticDB for MySQL supports tiered storage of hot and cold data. You can move the hot and cold data to different storage media to ensure high query performance of hot data and reduce storage costs of cold data.

Overview

In a big data scenario, a business table can contain large volumes of business data, such as log data, order data, or monitoring data. Over time, specific data is less frequently accessed and is considered cold. However, the cold data occupies the storage space. As a result, the storage costs are increased.

AnalyticDB for MySQL tiered storage of hot and cold data is applicable to tables partitioned by date and time. An AnalyticDB for MySQL cluster sorts the partitions in descending order based on the specified number of hot partitions and the partition key values. The largest N partitions are considered hot partitions, and the other partitions are considered cold partitions. The data of cold partitions can be moved to the lower-cost Object Storage Service (OSS) to reduce storage costs. The data of hot partitions remains in SSDs to ensure high query performance.

Prerequisites

Before you use tiered storage of hot and cold data in an AnalyticDB for MySQL cluster, make sure that the following requirements are met:

Billing rules

When you use a cluster, you are charged for the storage of hot and cold data based on the pay-as-you-go billing method. For more information, see Pricing.

Note

You can use storage plans to offset data storage costs in AnalyticDB for MySQL.

AnalyticDB for MySQL provides three policies for hot and cold data storage, which are cold storage, hot storage, and mixed storage.

Impact of partition quantity changes on the distribution of hot and cold partitions

Specify a storage policy of hot and cold data

Query the storage policy of hot and cold data

Syntax

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

Response parameters

Parameter Description
table_schema The name of the database.
table_name The name of the table.
storage_policy The storage policy. Valid values:HOT COLD MIXED
hot_partition_count The number of hot partitions.
cold_partition_count The number of cold partitions.
rt_total_size The total size of real-time data, which is the sum of the rt_data_size and rt_index_size parameters. Unit: bytes.
rt_data_size The size of real-time data. Unit: bytes.
rt_index_size The size of primary key and index data in real-time data. Unit: bytes.
hot_total_size The total size of data in hot partitions, which is the sum of the hot_data_size and hot_index_size parameters. Unit: bytes.
hot_data_size The size of data in hot partitions. Unit: bytes.
hot_index_size The size of primary key and index data in hot partitions. Unit: bytes.
cold_total_size The total size of data in cold partitions, which is the sum of the cold_data_size and cold_index_size parameters. Unit: bytes.
cold_data_size The size of data in cold partitions. Unit: bytes.
cold_index_size The size of primary key and index data in cold partitions. Unit: bytes.

Note:

Query the change progress of the storage policy of hot and cold data

After you change the storage policy of hot and cold data by executing the ALTER TABLE statement, you can query the change progress of the storage policy from the storage_policy_modify_progress table.

Syntax

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

Response parameters

Parameter Description
table_schema The name of the database.
table_name The name of the table.
task_id The ID of the storage policy change job.
source_storage_policy The original storage policy. Valid values:HOT COLD MIXED
source_hot_partition_count The number of original hot partitions.
dest_storage_policy The new storage policy. Valid values:HOT COLD MIXED
dest_hot_partition_count The number of new hot partitions.
hot_to_cold_partition_count The number of partitions changed from the hot partition to the cold partition.
cold_to_hot_partition_count The number of partitions changed from the cold partition to the hot partition.
hot_to_cold_data_size The size of data changed from hot partition to cold partition. Unit: bytes.
cold_to_hot_data_size The size of data changed from hot partition to cold partition. Unit: bytes.
hot_data_size_before_change The size of hot data before the storage policy is changed. Unit: bytes.
cold_data_size_before_change The size of cold data before the storage policy is changed. Unit: bytes.
hot_data_size_after_change The size of hot data after the storage policy is changed. Unit: bytes.
cold_data_size_after_change The size of cold data after the storage policy is changed. Unit: bytes.
start_time The start of the time range within which the storage policy is changed.
update_time The end of the time range within which the storage policy is changed.
progress The change progress of the storage policy. Unit: %.
status The change status of the storage policy. Valid values:INIT: No change starts. RUNNING: The change is in progress. FINISH: The change is complete.