- 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
- 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
- Miscellaneous Functions
- Precision Math
- 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 TABLE LIKE
CREATE TABLE
CREATE USER
DEALLOCATE
DELETE
DESC
DESCRIBE
DO
DROP COLUMN
DROP DATABASE
DROP INDEX
DROP TABLE
DROP USER
EXECUTE
EXPLAIN ANALYZE
EXPLAIN
FLUSH PRIVILEGES
FLUSH STATUS
FLUSH TABLES
GRANT <privileges>
INSERT
KILL [TIDB]
LOAD DATA
LOAD STATS
MODIFY COLUMN
PREPARE
RENAME INDEX
RENAME TABLE
REPLACE
REVOKE <privileges>
ROLLBACK
SELECT
SET [NAMES|CHARACTER SET]
SET PASSWORD
SET TRANSACTION
SET [GLOBAL|SESSION] <variable>
SHOW CHARACTER SET
SHOW COLLATION
SHOW [FULL] COLUMNS FROM
SHOW CREATE TABLE
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 STATUS
SHOW [GLOBAL|SESSION] VARIABLES
SHOW WARNINGS
START TRANSACTION
TRACE
TRUNCATE
UPDATE
USE
- Constraints
- Generated Columns
- Character Set
- Configuration
- Security
- Transactions
- System Databases
- Errors Codes
- Supported Client Drivers
- Garbage Collection (GC)
- Performance
- Key Monitoring Metrics
- Alert Rules
- Best Practices
- TiSpark
- TiDB Binlog
- Tools
- Overview
- Use Cases
- Download
- Mydumper
- Syncer
- Loader
- TiDB Data Migration
- TiDB Lightning
- sync-diff-inspector
- PD Control
- PD Recover
- TiKV Control
- TiDB Control
- FAQs
- Support
- Contribute
- Releases
- All Releases
- v2.1
- v2.0
- v1.0
- Glossary
You are viewing the documentation of an older version of the TiDB database (TiDB v2.1).
TiDB Lightning Table Filter
TiDB Lightning supports setting up black and white lists to ignore certain databases and tables. This can be used to skip cache tables, or manually partition the data source on a shared storage to allow multiple Lightning instances work together without interfering each other.
The filtering rule is similar to MySQL replication-rules-db
/replication-rules-table
.
Filtering databases
[black-white-list]
do-dbs = ["pattern1", "pattern2", "pattern3"]
ignore-dbs = ["pattern4", "pattern5"]
- If the
do-dbs
array in the[black-white-list]
section is not empty,- If the name of a database matches any pattern in the
do-dbs
array, the database is included. - Otherwise, the database is skipped.
- If the name of a database matches any pattern in the
- Otherwise, if the name matches any pattern in the
ignore-dbs
array, the database is skipped. - If a database’s name matches both the
do-dbs
andignore-dbs
arrays, the database is included.
The pattern can either be a simple name, or a regular expression in Go dialect if it starts with a ~
character.
Filtering tables
[[black-white-list.do-tables]]
db-name = "db-pattern-1"
tbl-name = "table-pattern-1"
[[black-white-list.do-tables]]
db-name = "db-pattern-2"
tbl-name = "table-pattern-2"
[[black-white-list.do-tables]]
db-name = "db-pattern-3"
tbl-name = "table-pattern-3"
[[black-white-list.ignore-tables]]
db-name = "db-pattern-4"
tbl-name = "table-pattern-4"
[[black-white-list.ignore-tables]]
db-name = "db-pattern-5"
tbl-name = "table-pattern-5"
- If the
do-tables
array is not empty,- If the qualified name of a table matched any pair of patterns in the
do-tables
array, the table is included. - Otherwise, the table is skipped
- If the qualified name of a table matched any pair of patterns in the
- Otherwise, if the qualified name matched any pair of patterns in the
ignore-tables
array, the table is skipped. - If a table’s qualified name matched both the
do-tables
andignore-tables
arrays, the table is included.
Note that the database filtering rules are applied before Lightning considers the table filtering rules. This means if a database is ignored by ignore-dbs
, all tables inside this database are not considered even if they matches any do-tables
array.
Example
To illustrate how these rules work, suppose the data source contains the following tables:
`logs`.`messages_2016`
`logs`.`messages_2017`
`logs`.`messages_2018`
`forum`.`users`
`forum`.`messages`
`forum_backup_2016`.`messages`
`forum_backup_2017`.`messages`
`forum_backup_2018`.`messages`
`admin`.`secrets`
Using this configuration:
[black-white-list]
do-dbs = [
"forum_backup_2018", # rule A
"~^(logs|forum)$", # rule B
]
ignore-dbs = [
"~^forum_backup_", # rule C
]
[[black-white-list.do-tables]] # rule D
db-name = "logs"
tbl-name = "~_2018$"
[[black-white-list.ignore-tables]] # rule E
db-name = "~.*"
tbl-name = "~^messages.*"
[[black-white-list.do-tables]] # rule F
db-name = "~^forum.*"
tbl-name = "messages"
First apply the database rules:
Database | Outcome |
---|---|
`logs` | Included by rule B |
`forum` | Included by rule B |
`forum_backup_2016` | Skipped by rule C |
`forum_backup_2017` | Skipped by rule C |
`forum_backup_2018` | Included by rule A (rule C will not apply) |
`admin` | Skipped since do-dbs is not empty and this does not match any pattern |
Then apply the table rules:
Table | Outcome |
---|---|
`logs`.`messages_2016` | Skipped by rule E |
`logs`.`messages_2017` | Skipped by rule E |
`logs`.`messages_2018` | Included by rule D (rule E will not apply) |
`forum`.`users` | Skipped, since do-tables is not empty and this does not match any pattern |
`forum`.`messages` | Included by rule F (rule E will not apply) |
`forum_backup_2016`.`messages` | Skipped, since database is already skipped |
`forum_backup_2017`.`messages` | Skipped, since database is already skipped |
`forum_backup_2018`.`messages` | Included by rule F (rule E will not apply) |
`admin`.`secrets` | Skipped, since database is already skipped |