# `TiDB Lightning` Import Mode

| Behavior                        | Physical Import Mode      | Logical Import Mode       |
| :------------------------------ | :------------------------ | :------------------------ |
| Speed                           | High `(100~500 GiB/hour)` | Low `(10~50 GiB/hour)`    |
| Resource consumption            | High                      | Low                       |
| Bypassing SQL processing        | Yes                       | No                        |
| `ACID` compliance during import | No                        | Yes                       |
| Target tables                   | Must be empty             | Can contain existing data |
| `TiDB` cluster version          | `>= v4.0.0`               | Any                       |
| Online importing                | No                        | Yes                       |
| Parallel importing              | Recommended               | Not recommended           |

-------------------------------------------------------------------------------------------
`TiDB Lightning` supports two import modes, configured by `backend`. The import mode determines the way data is imported into `TiDB`.

Physical import mode is an efficient and fast import mode that inserts data directly into `TiKV` nodes as key-value pairs without going through the `SQL` interface. It is suitable for importing up to `100 TB` of data. During physical import mode, `TiDB Lightning` first encodes data into key-value pairs and stores them in a local temporary directory, then uploads these key-value pairs to each `TiKV` node, and finally calls the `TiKV` `Ingest` interface to insert data into `TiKV's RocksDB`. If you need to perform initial import, consider physical import mode, which has higher import speed.

Logical Import Mode: `TiDB Lightning` first encodes the data into `SQL` statements and then runs these `SQL` statements directly for data import. If the cluster to be imported is in production, or if the target table to be imported already contains data, use logical import mode.

The preceding performance data on the slide is used to compare the import performance difference between the two modes. The actual import speed is affected by various factors such as hardware configuration, table schema, and the number of indexes.