- Introduction
- Concepts
- Architecture
- Key Features
- Horizontal Scalability
- MySQL Compatible Syntax
- Replicate from and to MySQL
- Distributed Transactions with Strong Consistency
- Cloud Native Architecture
- Minimize ETL with HTAP
- Fault Tolerance & Recovery with Raft
- Automatic Rebalancing
- Deployment and Orchestration with Ansible, Kubernetes, Docker
- JSON Support
- Spark Integration
- Read Historical Data Without Restoring from Backup
- Fast Import and Restore of Data
- Hybrid of Column and Row Storage
- SQL Plan Management
- Open Source
- Online Schema Changes
- How-to
- Get Started
- Deploy
- Hardware Recommendations
- From Binary Tarball
- Orchestrated Deployment
- Geographic Redundancy
- Data Migration with Ansible
- Configure
- Secure
- Transport Layer Security (TLS)
- Generate Self-signed Certificates
- Monitor
- Migrate
- Maintain
- Common Ansible Operations
- Backup and Restore
- Identify Abnormal Queries
- Scale
- Upgrade
- Troubleshoot
- Reference
- SQL
- MySQL Compatibility
- SQL Language Structure
- Data Types
- Functions and Operators
- Function and Operator Reference
- Type Conversion in Expression Evaluation
- Operators
- Control Flow Functions
- String Functions
- Numeric Functions and Operators
- Date and Time Functions
- Bit Functions and Operators
- Cast Functions and Operators
- Encryption and Compression Functions
- Information Functions
- JSON Functions
- Aggregate (GROUP BY) Functions
- Window Functions
- Miscellaneous Functions
- Precision Math
- List of Expressions for Pushdown
- SQL Statements
ADD COLUMN
ADD INDEX
ADMIN
ADMIN CANCEL DDL
ADMIN CHECKSUM TABLE
ADMIN CHECK [TABLE|INDEX]
ADMIN SHOW DDL [JOBS|QUERIES]
ALTER DATABASE
ALTER TABLE
ALTER USER
ANALYZE TABLE
BEGIN
CHANGE COLUMN
COMMIT
CREATE DATABASE
CREATE INDEX
CREATE ROLE
CREATE TABLE LIKE
CREATE TABLE
CREATE USER
CREATE VIEW
DEALLOCATE
DELETE
DESC
DESCRIBE
DO
DROP COLUMN
DROP DATABASE
DROP INDEX
DROP ROLE
DROP TABLE
DROP USER
DROP VIEW
EXECUTE
EXPLAIN ANALYZE
EXPLAIN
FLUSH PRIVILEGES
FLUSH STATUS
FLUSH TABLES
GRANT <privileges>
GRANT <role>
INSERT
KILL [TIDB]
LOAD DATA
LOAD STATS
MODIFY COLUMN
PREPARE
RECOVER TABLE
RENAME INDEX
RENAME TABLE
REPLACE
REVOKE <privileges>
REVOKE <role>
ROLLBACK
SELECT
SET DEFAULT ROLE
SET [NAMES|CHARACTER SET]
SET PASSWORD
SET ROLE
SET TRANSACTION
SET [GLOBAL|SESSION] <variable>
SHOW ANALYZE STATUS
SHOW CHARACTER SET
SHOW COLLATION
SHOW [FULL] COLUMNS FROM
SHOW CREATE TABLE
SHOW CREATE USER
SHOW DATABASES
SHOW ENGINES
SHOW ERRORS
SHOW [FULL] FIELDS FROM
SHOW GRANTS
SHOW INDEXES [FROM|IN]
SHOW INDEX [FROM|IN]
SHOW KEYS [FROM|IN]
SHOW PRIVILEGES
SHOW [FULL] PROCESSSLIST
SHOW SCHEMAS
SHOW STATUS
SHOW [FULL] TABLES
SHOW TABLE REGIONS
SHOW TABLE STATUS
SHOW [GLOBAL|SESSION] VARIABLES
SHOW WARNINGS
SPLIT REGION
START TRANSACTION
TRACE
TRUNCATE
UPDATE
USE
- Constraints
- Generated Columns
- Partitioning
- Character Set
- SQL Mode
- Views
- Configuration
- Security
- Transactions
- System Databases
- Errors Codes
- Supported Client Drivers
- Garbage Collection (GC)
- Performance
- Overview
- Understanding the Query Execution Plan
- The Blocklist of Optimization Rules and Expression Pushdown
- Introduction to Statistics
- TopN and Limit Push Down
- Optimizer Hints
- Check the TiDB Cluster Status Using SQL Statements
- Execution Plan Binding
- Statement Summary Table
- Tune TiKV
- Operating System Tuning
- Column Pruning
- Key Monitoring Metrics
- Alert Rules
- Best Practices
- TiSpark
- TiKV
- TiDB Binlog
- Tools
- TiDB in Kubernetes
- FAQs
- Support
- Contribute
- Releases
- All Releases
- v3.0
- v2.1
- v2.0
- v1.0
- Glossary
You are viewing the documentation of an older version of the TiDB database (TiDB v3.0).
TiDB Lightning TiDB-backend
TiDB Lightning supports two backends: Importer and TiDB. It determines how tidb-lightning
delivers data into the target cluster.
The Importer-backend (default) requires tidb-lightning
to first encode the SQL or CSV data into KV pairs, and relies on the external tikv-importer
program to sort these KV pairs and ingest directly into the TiKV nodes.
The TiDB-backend requires tidb-lightning
to encode these data into SQL INSERT
statements, and has these statements executed directly on the TiDB node.
Back end | Importer | TiDB |
---|---|---|
Speed | Fast (~300 GB/hr) | Slow (~50 GB/hr) |
Resource usage | High | Low |
ACID respected while importing | No | Yes |
Target tables | Must be empty | Can be populated |
Deployment for TiDB-backend
When using the TiDB-backend, you no longer need tikv-importer
. Compared with the standard deployment procedure, the TiDB-backend deployment has the following two differences:
- Steps involving
tikv-importer
can all be skipped. - The configuration must be changed to indicate the TiDB-backend is used.
Hardware requirements
The speed of TiDB Lightning using TiDB-backend is limited by the SQL processing speed of TiDB. Therefore, even a lower-end machine may max out the possible performance. The recommended hardware configuration is:
- 16 logical cores CPU
- An SSD large enough to store the entire data source, preferring higher read speed
- 1 Gigabit network card
Ansible deployment
The
[importer_server]
section ininventory.ini
can be left blank.... [importer_server] # keep empty [lightning_server] 192.168.20.10 ...
The
tikv_importer_port
setting ingroup_vars/all.yml
is ignored, and the filegroup_vars/importer_server.yml
does not need to be changed. But you need to editconf/tidb-lightning.yml
and change thebackend
setting totidb
.... tikv_importer: backend: "tidb" # <-- change this ...
Bootstrap and deploy the cluster as usual.
Mount the data source for TiDB Lightning as usual.
Start
tidb-lightning
as usual.
Manual deployment
You do not need to download and configure tikv-importer
. You can download TiDB Lightning from here.
Before running tidb-lightning
, add the following lines into the configuration file:
[tikv-importer]
backend = "tidb"
or supplying the --backend tidb
arguments when executing tidb-lightning
.
Conflict resolution
The TiDB-backend supports importing to an already-populated table. However, the new data might cause a unique key conflict with the old data. You can control how to resolve the conflict by using this task configuration.
[tikv-importer]
backend = "tidb"
on-duplicate = "replace" # or "error" or "ignore"
Setting | Behavior on conflict | Equivalent SQL statement |
---|---|---|
replace | New entries replace old ones | REPLACE INTO ... |
ignore | Keep old entries and ignore new ones | INSERT IGNORE INTO ... |
error | Abort import | INSERT INTO ... |
Migrating from Loader to TiDB Lightning TiDB-backend
TiDB Lightning using the TiDB-backend can completely replace functions of Loader. The following list shows how to translate Loader configurations into TiDB Lightning configurations.
Loader | TiDB Lightning |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|