PolarDB supports data compression at the storage layer. After the storage compression feature is enabled, user data is compressed by blocks at the storage layer based on a high compression ratio. This significantly reduces storage usage and storage costs. This topic describes how to enable the storage compression feature and view the storage usage after you enable the feature.
Prerequisites
Your PolarDB cluster is of Enterprise Edition. For information about how to view the cluster version, see Engine versions 5.6, 5.7, and 8.0.
Your cluster is of Cluster Edition and runs one of the following versions:
PolarDB for MySQL 5.6 whose revision version is 5.6.1.0.40.1 or later.
PolarDB for MySQL 5.7 whose revision version is 5.7.1.0.29.1 or later.
PolarDB for MySQL 8.0.1 whose revision version is 8.0.1.1.36.3 or later.
PolarDB for MySQL 8.0.2 whose revision version is 8.0.2.2.19 or later.
Limits
You can enable the storage compression feature only for PolarDB clusters that use the PSL4 storage type.
You cannot enable the storage compression feature for PolarDB clusters that use X-Engine.
The storage compression feature compresses data storage and does not compress log storage.
You cannot enable the storage compression feature for PolarDB clusters that contains ongoing data migration tasks.
The PolarDB cluster was created no earlier than September 1, 2023.
Usage notes
Make sure that the size of the data to be compressed does not exceed the upper limit. Otherwise, an out of memory (OOM) error occurs even if you enable the storage compression feature.
Your business is not interrupted or affected when you enable the storage compression feature.
The storage compression feature cannot be disabled after it is enabled.
The following rules related to the free quota of level-1 backups are applicable after you enable the storage compression feature. For more information about the free quota of level-1 backups for a cluster, see the Free quota section of the "Billing rules for backup storage that exceeds the free quota" topic.
If the storage of the cluster is billed on a pay-as-you-go basis, the free quota of level-1 backups after you enable the storage compression feature is calculated by using the following formula: Storage usage of the database before compression × 50%.
If the storage of the cluster is billed on a subscription basis, the free quota of level-1 backups after you enable the storage compression feature is calculated by using the following formula: Max (subscription-billed storage capacity, storage usage of the database before compression) × 50%.
Example:
The storage of a cluster uses the subscription billing method, the subscription-billed storage capacity of the cluster is 2 TB, and the storage usage of the cluster is 1.6 TB. After you enable the storage compression feature, the storage usage of the cluster is compressed to 0.5 TB. In this case, you can manually reduce the subscription-billed storage capacity to 1 TB. For more information, see Manually scale up or scale down the storage capacity.
The free quota of level-1 backups for the cluster is 0.8 TB. The free quota is calculated by using the following formula: Max(1 TB, 1.6 TB) × 50% = 1.6 TB × 50% = 0.8 TB.
Procedure
Log on to the PolarDB console.
In the upper-left corner of Clusters page, select the region where the cluster is deployed.
Find the cluster that you want to manage and click the cluster ID.
On the Basic Information page, click Enable Storage Compression in the upper-right corner of the Distributed Storage section. In the message that appears, click OK.
After you enable the storage compression feature, the cluster enters the Changing Configurations state. After the cluster returns to the Running state, the storage compression feature is enabled.
After you enable the storage compression feature, the cluster enters the Changing Configurations state. After the cluster returns to the Running state, the storage compression feature is enabled.
After you enable the storage compression feature, you can check the storage usage after compression in the Distributed Storage section of the Basic Information page.
You are charged storage usage fees based on the size of physical data after compression. You can purchase storage plans to offset storage usage fees. For information about how to purchase a storage plan, see Purchase a storage plan.