Cold data archiving moves infrequently accessed data from PolarDB hot storage to lower-cost storage, reducing storage costs while keeping archived data queryable. Use this guide to archive, query, modify, and delete cold data in PolarDB for MySQL.
Before archiving, confirm the archiving format you need and verify your cluster meets the version requirements listed below.
Prerequisites
Before you begin, ensure that you have:
A PolarDB for MySQL cluster (Cluster Edition or Multi-master Cluster (Limitless) Edition) that meets the version requirements for your target format (see Scope)
(Required for X-Engine archiving) High-compression engine (X-Engine) enabled
Choose a format
Select a format based on your query workload, storage budget, and whether you need transaction support.
| Factor | CSV | ORC | X-Engine |
|---|---|---|---|
| Query type | Row-based reads, row store nodes | Analytical (AP) queries, column store nodes | Transactional (TP) or analytical (AP) |
| Query speed | Poor (roughly 1/5–1/10 of InnoDB); faster than ORC on row store nodes | Poor (roughly 1/5–1/10 of InnoDB); best for AP queries on column store nodes | Fast (roughly 30% slower than InnoDB) |
| Archiving speed | Fast (single-threaded) | Slow (single-threaded) | Fast (data stays in PolarDB storage) |
| Storage reduction | Same as InnoDB without indexes | 45% of CSV storage | 10%–30% of InnoDB storage |
| Transaction support | No | No | Yes |
| Index support | No | No | Yes |
| Backup and recovery | Not supported | Not supported | Supported |
| Modifying archived data | Import back to PolarDB first | Run DML directly on the archived table | Run DML directly on the archived table |
| Open-source format | Yes | Yes | No |
When to use each format:
CSV: Use when you need fast archiving and your queries are primarily row-based reads on row store nodes.
ORC: Use when your primary workload is analytical queries on column store nodes and you need better storage efficiency than CSV.
X-Engine: Use when you need transaction support, index access, or backup and recovery for archived data. X-Engine stores data in PolarDB storage space, providing significantly faster access than OSS-based formats.
Scope
Your cluster must meet the following kernel version requirements for the archiving format you plan to use.
CSV format
| Cluster type | Required version |
|---|---|
| Cluster Edition | MySQL 8.0.1 revision 8.0.1.1.47 or later, or MySQL 8.0.2 revision 8.0.2.2.10 or later |
| Multi-master Cluster (Limitless) Edition | Kernel version 8.0.1.0.13 or later |
ORC format
| Cluster type | Required version |
|---|---|
| Cluster Edition | Revision 8.0.2.2.30 or later |
| Multi-master Cluster (Limitless) Edition | Revision 8.0.2.2.30 or later |
X-Engine format
| Table type | Required version |
|---|---|
| Standard table | MySQL 8.0.1 revision 8.0.1.1.31 or later, or MySQL 8.0.2 revision 8.0.2.2.12 or later |
| Partitioned table | MySQL 8.0.2 revision 8.0.2.2.12 or later |
| X-Engine columnar table | MySQL 8.0.2 revision 8.0.2.2.33 or later |
Applicable scope
Archiving in CSV format
If the product edition is Cluster Edition, the Milvus version must be one of the following:
MySQL 8.0.1, minor version 8.0.1.1.47 or later.
MySQL 8.0.2, revision version 8.0.2.2.10 or later.
For the Multi-master Cluster (Limitless) Edition, the kernel version must be 8.0.1.0.13 or later.
Archiving in ORC format
For the Cluster Edition, the revision version must be 8.0.2.2.30 or later.
For the Multi-master Cluster (Limitless) Edition, the revision version must be 8.0.2.2.30 or later.
Archiving in X-Engine format
Archiving standard tables:
MySQL 8.0.1 with revision 8.0.1.1.31 or later.
MySQL 8.0.2 with revision 8.0.2.2.12 or later.
Archiving partitioned tables: MySQL 8.0.2 with revision 8.0.2.2.12 or later.
Archiving as an X-Engine column-oriented table: MySQL 8.0.2 with revision 8.0.2.2.33 or later.
Usage notes
After archiving, cold data is stored in the system-default OSS, not your own OSS bucket. Archived data is viewable only in the PolarDB console.
Backup and recovery are not supported for CSV and ORC archives. Backups do not include data archived to OSS, so you cannot restore databases or tables, recover backups, or perform point-in-time recovery using backups.
CSV archived tables on OSS are read-only. To run
INSERT,UPDATE, orDELETEon archived CSV data, import it back to PolarDB storage first. ORC archived tables support direct DML operations without importing.Deleting OSS files is asynchronous. Complete deletion occurs only after all nodes in the cluster no longer depend on the OSS file, and may be delayed during high traffic.
Partitioned table archiving has two distinct methods with different behaviors:
Partitioned table archiving: Archives the partition in place, changing its storage medium from PolarDB (hot storage) to OSS (cold storage). The partition remains in the original table, which becomes a hybrid partitioned table.
Partitioned table archiving to OSS external table: Moves the partition data into a new, independent OSS external table. The original table loses that partition.
Archive cold data
To modify cold data on OSS infrequently, use the ALTER syntax to import cold data from OSS back to PolarDB storage space for modification. After importing, the cold data on OSS is simultaneously deleted. After modifying the data, archive the modified table data to OSS again.
Standard Tables
Syntax
ALTER TABLE table_name ENGINE[=]engine_name;Parameters
Parameter | Description |
table_name | The name of the OSS table to import. |
engine_name | The engine type after importing. |
Notes
When an OSS table is read-only, it does not support modification operations (INSERT, UPDATE, and DELETE). To modify archived cold data, convert the OSS table to a read-write table, such as an InnoDB table. When modifying a read-only OSS table, the error message is as follows:
1036 - Table 't' is read onlyExample
In the oss_test database, import the OSS table t back to PolarDB storage space.
ALTER TABLE `oss_test`.`t` ENGINE = InnoDB;Modify the data of the InnoDB table t. After modifying the data, archive the InnoDB engine table t to OSS again. For example:
ALTER TABLE t ENGINE = CSV CONNECTION = 'default_oss_server';or
ALTER TABLE t ENGINE = CSV STORAGE OSS;Partitioned Tables
Syntax
ALTER TABLE table_name REORGANIZE PARTITION part_name INTO (partition_definition);Parameters
Parameter | Description |
table_name | The name of the OSS table to import. |
part_name | The name of the partition to import. |
partition_definition | Keep consistent with the |
Example
In the database, import the data from partition p1 of the partitioned table t archived on OSS back to PolarDB storage space.
ALTER TABLE t REORGANIZE PARTITION p1 INTO(PARTITION p1 values less than(100));Archive to OSS
Enable cold data archiving, then choose the archiving method based on your table type.
Standard tables
Partitioned tables
Manually archive some partitions to OSS: Archive partitioned tables. To move partitions into a separate table, see Archive partitioned tables to OSS external tables
Create a Data Lifecycle Management (DLM) policy to automatically archive cold data (CSV format only): Automatically archive cold data
Archive to X-Engine
Enable cold data archiving and enable the high-compression engine (X-Engine), then choose the archiving method based on your table type.
Standard tables
Partitioned tables
Manually archive partitions to X-Engine: Archive as X-Engine format
Create a DLM policy to automatically archive cold data: Archive partitioned tables as X-Engine format
Query cold data
Standard tables
Query archived data without changing how you access the table, regardless of the archiving format.
Partitioned tables
Query behavior depends on how the partition was archived:
Archived to an OSS external table: Modify the table access method to query archived data. Access the specific archived table directly. For details, see Archive partitioned tables to OSS external tables.
Archived in place (hybrid partitioned table): The original table becomes a hybrid partitioned table containing both hot and cold partitions. Query partition data across different storage engines in one of the following ways: For more details, see Query hybrid partitions.
Set
hybrid_partition_query_mix_engine_enabledtoONto return data from InnoDB, X-Engine, and OSS partitions: ``sql -- t1 is a hybrid partitioned table. SELECT * FROM t1;``Set
hybrid_partition_query_mix_engine_enabledtoOFFto return data only from InnoDB and X-Engine partitions: ``sql -- t1 is a hybrid partitioned table. SELECT * FROM t1;``Specify a partition name to query data from a single partition of any storage engine type: ``
sql -- t1 is a hybrid partitioned table. p1 is the partition name. SELECT * FROM t1 PARTITION (p1);``
Archived cold data is stored in a single-table, multi-file format. Use parallel query for better performance when querying cold data. For details, see Cold data parallel query.
Modify cold data
OSS tables are read-only. To modify archived data, import it back to PolarDB storage, make your changes, and re-archive.
Standard tables
Syntax
ALTER TABLE table_name ENGINE[=]engine_name;Parameters
| Parameter | Description |
|---|---|
table_name | The name of the OSS table to import |
engine_name | The target storage engine after importing (for example, InnoDB) |
Example
Import the OSS table t in the oss_test database back to PolarDB storage:
ALTER TABLE `oss_test`.`t` ENGINE = InnoDB;Modify the data of the InnoDB table t, then re-archive it to OSS:
ALTER TABLE t ENGINE = CSV CONNECTION = 'default_oss_server';Or:
ALTER TABLE t ENGINE = CSV STORAGE OSS;Attempting to runINSERT,UPDATE, orDELETEon a read-only OSS table returns the following error:1036 - Table 't' is read only
Partitioned tables
Syntax
ALTER TABLE table_name REORGANIZE PARTITION part_name INTO (partition_definition);Parameters
| Parameter | Description |
|---|---|
table_name | The name of the table containing the partition to import |
part_name | The name of the partition to import |
partition_definition | The partition definition — keep consistent with the original partition definition |
Example
Import partition p1 from a partitioned table t archived on OSS back to PolarDB storage:
ALTER TABLE t REORGANIZE PARTITION p1 INTO(PARTITION p1 values less than(100));Delete cold data
Deleting or importing a table from OSS does not automatically delete the corresponding OSS files. After confirming the data is no longer needed, delete the OSS files explicitly.
Deleting corresponding OSS files requires the following minor versions:
8.0.1 with minor version 8.0.1.1.42 or later
8.0.2 with minor version 8.0.2.2.23 or later If your cluster does not meet these requirements, upgrade the minor version first. For details, see Manage minor versions.
For more details on deleting OSS files, see Delete corresponding files on OSS.
Standard tables and OSS external tables
Drop the archived table:
DROP TABLE table_name;Delete the corresponding OSS files:
CALL dbms_oss.delete_table_file('database_name', 'table_name');
Partitioned tables
Delete the corresponding OSS files:
CALL dbms_oss.delete_table_file('database_name', 'table_name');FORCE STORAGE OSS option
The FORCE STORAGE OSS option requires PolarDB for MySQL version 8.0.2 with minor version 8.0.2.2.29 or later.Use FORCE STORAGE OSS to delete associated OSS files in a single step, without running dbms_oss.delete_table_file separately.
Standard tables and OSS external tables
DROP TABLE table_name [FORCE STORAGE OSS];FORCE STORAGE OSS automatically deletes the associated OSS storage files when you drop the table schema.
Partitioned tables
ALTER TABLE table_name DROP PARTITION part_name [FORCE STORAGE OSS];FORCE STORAGE OSS enables synchronous deletion of the partition metadata and its corresponding OSS storage files.
CHANGE PARTITION ENGINE
ALTER TABLE table_name CHANGE PARTITION part_name ENGINE = CSV|ORC [FORCE STORAGE OSS]FORCE STORAGE OSS enables force overwrite, automatically replacing OSS files with the same name.