How to Quickly Delete a Column from a Large Table in TiDB

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

Original topic: tidb如何快速删除大表中得某一列

| username: hyman

  1. There is currently a production environment requirement to quickly delete a column of data from a large table without affecting the normal use of the production environment. The data volume is over 1 billion rows.
  2. The current idea is to rename this column first, and then add a new column with the same name. Will this method affect TiDB, are there any points to be aware of, or is there a better way?
| username: TI表弟 | Original post link

SQL on KV
TiDB automatically maps SQL structures to KV structures. For details, you can refer to the document "Understanding TiDB Technology in Three Articles - Computing". In short, TiDB performs the following operations:

A row of data is mapped to a KV, with the Key constructed using TableID as the prefix and row ID as the suffix.
An index is mapped to a KV, with the Key constructed using TableID+IndexID as the prefix and the index value as the suffix.

Theoretically, there is no significant impact. The underlying data storage uses the row ID as metadata. As long as it does not involve modifying the metadata, theoretically, there should be no major issues.

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

No impact, TiDB supports online DDL, modifying the table structure will not have a significant impact on the production environment.

| username: xingzhenxiang | Original post link

DDL operations are completed very quickly and seem to have no impact: The DROP COLUMN statement is used to delete a column from a specified table. In TiDB, COLUMN is an online operation and does not block data reads and writes in the table.