How to Add Partitions to a Single Table with 300GB of Data in TiDB

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb怎样在单表300G数据量的表上添加分区

| username: TiDBer_FMWXa7ja

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] 6.5
[Reproduction Path]
[Encountered Problem: Problem Phenomenon and Impact] Previously, partitions were not added when creating the table. Now the single table data volume has reached 300GB, with over 1 billion records. How can partitions be added?
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]

| username: tidb菜鸟一只 | Original post link

First, export the data, then rebuild the table structure, and finally import the data.

| username: 裤衩儿飞上天 | Original post link

Logical migration

| username: Kongdom | Original post link

Currently, TiDB does not support modifying a regular table into a partitioned table. You need to create a new table and import the data into the partitioned table.

| username: 我是咖啡哥 | Original post link

Our usual approach is to create a new partition table, perform data synchronization, and then rename it.

| username: Kongdom | Original post link

Yes, the data synchronization step is indeed difficult to handle right now.