Before you archive cold data, confirm your desired archive format and ensure that your cluster meets the requirements. For more information, see Archive format comparison and Prerequisites.
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.
Archive cold data
Archive to OSS: You must first enable cold data archiving. When archiving cold data, you can choose to archive common tables or partitioned tables.
Common tables
Partitioned tables
You can manually archive specific partitions of a partitioned table in place or archive them to an OSS external table. For more information, see Archive partitions in place or Archive partitions to an OSS external table.
Create a data lifecycle management (DLM) policy to automatically archive cold data. For more information, see Automatically archive cold data.
Archive to X-Engine: You must first enable cold data archiving and the high-compression engine (X-Engine). When archiving cold data, you can choose to archive common tables or partitioned tables.
Common tables
Partitioned tables
You can manually archive specific partitions of a partitioned table to X-Engine partitions. For more information, see Archive data to X-Engine.
Create a data lifecycle management (DLM) policy to automatically archive cold data. For more information, see Archive partitioned tables to X-Engine.
Query cold data
Common tables
Regardless of the archive format you choose, you can query the archived data without changing how you access the table.
Partitioned tables
Archive to an OSS external table: Querying this data requires a different access method: you must query the specified archive table. For more information, see Archive partitions to an OSS external table.
Archive partitions in place: The table becomes a hybrid partitioned table after archiving. For more information, see Query hybrid partitions.
You can query partition data stored across different engines by using one of the following three methods.
Set the
hybrid_partition_query_mix_engine_enabledparameter to ON. When you run a query, the result set includes partition data from the InnoDB engine, X-Engine, and OSS. Example:-- t1 is a hybrid partitioned table SELECT * FROM t1;Set the
hybrid_partition_query_mix_engine_enabledparameter to OFF. When you run a query, the result set includes only partition data from the InnoDB engine and X-Engine. Example:-- t1 is a hybrid partitioned table SELECT * FROM t1;Specify a partition name: You can retrieve partition data from any engine type by specifying the partition name in your query. Example:
-- t1 is a hybrid partitioned table, and p1 is the name of the partition to query. SELECT * FROM t1 partition (p1);
The system stores archived cold data in a multi-file format for each table. To optimize query performance, use a parallel query. For more information, see Parallel query on cold data.
Modify cold data
To infrequently modify cold data stored on Object Storage Service (OSS), use the ALTER statement to move it back to the PolarDB storage space for modification. The system then automatically deletes the data from OSS. After you modify the data, you can archive the table data to OSS again.
Common tables
Syntax
ALTER TABLE table_name ENGINE[=]engine_name;Parameters
Parameter | Description |
table_name | The name of the OSS table to move back to the PolarDB storage space. |
engine_name | The storage engine to use after the table is moved back. |
Usage notes
OSS tables are read-only. You cannot modify them by usingINSERT,UPDATE, orDELETE statements. To modify archived cold data, you must convert the OSS table into a read-write table, such as an InnoDB table. Attempting to modify a read-only OSS table returns the following error:
1036 - Table 't' is read onlyExample
Move the OSS table t from the oss_test database back to the PolarDB storage space.
ALTER TABLE `oss_test`.`t` ENGINE = InnoDB;Modify the data in the InnoDB tablet. After the modification is complete, archive the tablet from the InnoDB engine back to OSS. Example:
ALTER TABLE t ENGINE = CSV CONNECTION = 'default_oss_server';or
ALTER TABLE t ENGINE = CSV STORAGE OSS;Partitioned tables
To modify cold data in a partitioned table, your PolarDB for MySQL cluster must be version 8.0.2 with revision version 8.0.2.2.34 or later.
Syntax
ALTER TABLE table_name REORGANIZE PARTITION part_name INTO (partition_definition);Parameters
Parameter | Description |
table_name | The name of the OSS table to move back. |
part_name | The name of the partition to move back. |
partition_definition | This must be consistent with the |
Example
Move the data in partition p1 of the partitioned table t, which is archived on OSS, back to the PolarDB storage space.
ALTER TABLE t REORGANIZE PARTITION p1 INTO(PARTITION p1 values less than(100));Delete cold data
Only PolarDB for MySQL clusters of the following versions support deleting the corresponding files on OSS:
Version 8.0.1, and the minor version must be 8.0.1.1.42 or later.
Version 8.0.2, and the minor version must be 8.0.2.2.23 or later.
If your cluster's minor version does not meet the preceding requirements, you cannot delete the corresponding files on OSS. Upgrade your cluster's minor version. For more information, see Minor version management.
After you delete a table on OSS or import it back to PolarDB storage space, the files on OSS are not automatically deleted. After you confirm that the data is no longer needed, delete the corresponding files on OSS as follows. For more information, see Delete the corresponding files on OSS.
Common tables and OSS external tables
Use
DROP TABLEto delete the archived table. Then, run theCALL dbms_oss.delete_table_file('database_name', 'table_name');command to delete the corresponding files on OSS.Partitioned tables
Run the
CALL dbms_oss.delete_table_file('database_name', 'table_name');command to delete the corresponding files on OSS.
The operation to delete the corresponding files on OSS is performed asynchronously. The files are completely deleted only after all nodes in the cluster no longer depend on them. This process may be delayed when traffic is heavy.
The FORCE STORAGE OSS option
The FORCE STORAGE OSS option to forcibly delete OSS files is supported only on PolarDB for MySQL 8.0.2 clusters with a minor version of 8.0.2.2.29 or later.
Common tables and OSS external tables
DROP TABLE table_name [FORCE STORAGE OSS];NoteThe FORCE STORAGE OSS option of the DROP TABLE command provides a one-click cleanup feature. It automatically deletes the associated OSS storage files when you delete the table structure.
Partitioned tables
ALTER TABLE table_name DROP PARTITION part_name [FORCE STORAGE OSS];NoteThe DROP PARTITION clause of the ALTER TABLE statement, when used with the FORCE STORAGE OSS option, lets you synchronously delete the metadata of a partitioned table and its corresponding OSS storage files.
CHANGE PARTITION ENGINE
ALTER TABLE table_name CHANGE PARTITION part_name ENGINE = CSV|ORC [FORCE STORAGE OSS]NoteThe cold data archiving feature of CHANGE PARTITION ENGINE provides a forced overwrite mechanism that automatically replaces files with the same name.
Comparison of archive formats
Use the following comparison to help you choose the right format for archiving your cold data.
Archiving standard tables, OSS external tables, and partitioned tables has certain limitations. Review these limitations before archiving data to avoid impacting your business.
Archived cold data is stored in the system's default Object Storage Service (OSS) bucket, not in your own. Currently, you can view the list of archived data only in the PolarDB console.
Descriptions of partitioned table archiving methods:
Partitioned Table Archiving: Archives a specific partition in a partitioned table in place. The data remains in the original table, but the storage medium for that partition changes from PolarDB (hot storage) to OSS (cold storage), and the table becomes a hybrid partitioned table containing both hot and cold partitions.
Archive a partition to an OSS external table: This method moves the data from a partition to a new, separate OSS external table. The original partition is then deleted from the table.
Item | CSV | ORC | X-Engine |
Open source format | Yes | Yes | No |
Archiving method |
| Manual archiving: |
|
Archiving speed | Fast Note Only single-threaded archiving is supported. | Slow Note Only single-threaded archiving is supported. | Fast Note Data is archived to PolarStore storage space. |
Query speed |
Note Both single-threaded and multi-threaded data reads are supported. |
Note Only single-threaded data reads are supported. |
|
Transaction support | No | No | Yes |
Indexing capability | No | No | Yes |
How to modify archived data | Archived tables in OSS are read-only. To modify the data, you must import it from OSS back to the PolarDB storage space. | You can perform DML operations on archived tables. | |
Storage space used | The storage space is equivalent to that of tables without indexes in the InnoDB engine. | For the same data volume, uses 45% of the storage space required by the CSV format. | Compared to the InnoDB engine, storage space can be compressed to 10% to 50% of the original size. The specific compression ratio depends on the data characteristics. |
Backup and restore | Not supported. Note
| Supported. | |
Impact after archiving |
|
| After archiving, you can query the archived data without changing how you access the table. |