TiDB — Distributed SQL Database with MySQL Compatibility
TiDB is an open-source, cloud-native, distributed SQL database that supports hybrid transactional and analytical processing (HTAP). MySQL-compatible wire protocol, horizontal scalability, strong consistency, and elastic scaling.
What it is
TiDB is an open-source, cloud-native, distributed SQL database that supports hybrid transactional and analytical processing (HTAP). It speaks the MySQL wire protocol, so existing MySQL applications can connect to TiDB with minimal code changes. Under the hood, TiDB separates compute and storage, enabling horizontal scalability, strong consistency, and elastic scaling without manual sharding.
Engineering teams running MySQL at scale who hit single-node limits benefit most from TiDB. It is designed for applications that need both OLTP (transactions) and OLAP (analytics) without maintaining separate databases.
How it saves time or tokens
TiDB eliminates manual sharding, which is the biggest time sink in scaling MySQL. Instead of rewriting application code to route queries across shards, TiDB handles distribution transparently. The HTAP capability removes the need to maintain a separate analytics database and ETL pipeline, saving the engineering time of keeping two systems in sync.
How to use
- Install TiUP (TiDB's package manager) and start a local playground
- Connect with any MySQL client using the standard MySQL protocol
- Scale out by adding TiKV storage nodes or TiDB compute nodes
Example
# Install TiUP
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source ~/.zshrc
# Start a local playground cluster
tiup playground
# Connect with standard MySQL client
mysql -h 127.0.0.1 -P 4000 -u root
# Use standard SQL
CREATE DATABASE myapp;
USE myapp;
CREATE TABLE users (id BIGINT PRIMARY KEY AUTO_RANDOM, name VARCHAR(255));
INSERT INTO users (name) VALUES ('Alice');
SELECT * FROM users;
Related on TokRepo
- AI tools for database — Browse database tools and solutions
- Featured workflows — Discover top-rated workflows across categories
Common pitfalls
- AUTO_INCREMENT behaves differently in distributed mode; use AUTO_RANDOM for primary keys to avoid hotspots
- Some MySQL features (stored procedures, certain window functions) have limited support; check TiDB's compatibility matrix
- A minimum production deployment requires 3 PD nodes, 3 TiKV nodes, and 2 TiDB nodes, which is significant infrastructure
Frequently Asked Questions
TiDB supports the MySQL wire protocol and most MySQL syntax. Many applications work without code changes. However, some MySQL-specific features like stored procedures, triggers, and certain functions differ. Test your application against TiDB before migrating.
TiDB separates compute (TiDB nodes) from storage (TiKV nodes). You add TiKV nodes to increase storage capacity and TiDB nodes to handle more connections. Data is automatically rebalanced across nodes without downtime.
HTAP means hybrid transactional and analytical processing. TiDB handles both OLTP workloads (inserts, updates, point queries) and OLAP workloads (aggregations, joins, analytics) in one database using TiFlash, a columnar storage engine.
Yes. TiDB is open-source under the Apache 2.0 license. PingCAP (the company behind TiDB) offers a managed cloud service (TiDB Cloud) with paid tiers for teams that prefer not to manage infrastructure.
Both are distributed SQL databases. TiDB uses MySQL protocol compatibility; CockroachDB uses PostgreSQL compatibility. TiDB has stronger HTAP capabilities via TiFlash. CockroachDB emphasizes multi-region deployments. Choose based on your protocol preference and workload type.
Citations (3)
- TiDB GitHub— Open-source distributed SQL with MySQL compatibility
- TiDB Documentation— HTAP capability with TiFlash columnar storage
- PingCAP Website— TiUP deployment and management tool
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.