TiDB
TiDB is an open-source distributed SQL database that combines a MySQL-compatible interface with horizontal scalability and strong ACID consistency across multiple nodes.
Publisher review
TiDB is an open-source distributed SQL database that combines a MySQL-compatible interface with horizontal scalability and strong ACID consistency across multiple nodes. It is designed for organizations that have outgrown single-node databases and need to handle both high-volume transactions (OLTP) and real-time analytics (OLAP) on a unified platform without manual sharding. The architecture separates compute from storage: TiDB servers handle SQL parsing and query planning, while TiKV (row-based storage) and TiFlash (columnar storage) manage data persistence. This separation allows independent scaling of compute and storage resources. TiDB uses the Raft consensus protocol for replication and fault tolerance, with placement rules that can pin Raft leaders closer to write-heavy regions to reduce latency. In independent benchmarks on comparable cloud instances (c5.4xlarge, three regions), TiDB achieved 52K TPS on OLTP mixed workloads, 95K QPS on read-heavy patterns, and 40K TPS on write-heavy patterns, with P99 write latencies of 30-80ms in geo-distributed setups. Its real-time analytics capability is rated as "Excellent" in the same benchmarks, significantly ahead of CockroachDB and YugabyteDB, thanks to TiFlash's columnar engine that bypasses row-based storage for analytical queries. The database is fully compatible with the MySQL wire protocol, meaning existing MySQL applications can often connect with minimal code changes. TiDB is available as a self-managed deployment or as a fully managed cloud service (TiDB Cloud) on AWS, Google Cloud, and Azure. The cloud offering includes a free Starter tier (25 GiB row storage, 25 GiB column storage, 2 vCPU) and a Dedicated tier with per-minute billing for compute nodes, starting at $0.4416/hour for a 4 vCPU TiDB node in us-west-2. TiDB is owned and operated by PingCAP, the original developer and current maintainer of the project.
TiDB's key capability is its hybrid transactional/analytical processing (HTAP) design, which lets users run real-time analytics directly on fresh transactional data without ETL pipelines. The TiFlash columnar storage engine replicates data from TiKV asynchronously, enabling sub-second analytical queries on the same cluster that handles OLTP writes. This eliminates the need for a separate data warehouse for many use cases. The database also supports advanced features like placement rules for data locality (e.g., pinning specific tables to certain regions for compliance or performance), automatic region-based sharding that rebalances data as nodes are added or removed, and a built-in dashboard for monitoring cluster health and query performance. TiDB Cloud adds automated backups, point-in-time recovery, and one-click vertical/horizontal scaling through a web console. The Dedicated tier allows selecting node sizes from 4 vCPU/16 GiB up to 32 vCPU/128 GiB for TiDB and TiKV, and up to 32 vCPU/256 GiB for TiFlash, with costs varying by cloud provider and region. For example, a 16 vCPU TiKV node costs $1.7664/hour on AWS in Oregon, while a 32 vCPU TiFlash node costs $3.5328/hour. The free Starter tier is sufficient for development and small-scale testing but is not recommended for production workloads.
In the distributed SQL market, TiDB competes directly with CockroachDB and YugabyteDB. The primary differentiator is MySQL compatibility: TiDB supports the MySQL wire protocol and SQL dialect, while CockroachDB is PostgreSQL-compatible and YugabyteDB offers full PostgreSQL compatibility. For teams with existing MySQL applications or expertise, TiDB provides the smoothest migration path. Performance-wise, TiDB leads on raw throughput in OLTP mixed workloads (52K TPS vs. 45K for CockroachDB and 48K for YugabyteDB) and is the clear winner for real-time analytics due to TiFlash. However, CockroachDB offers a simpler operational model with its tightly coupled architecture (no separate compute/storage components), while YugabyteDB provides the deepest PostgreSQL compatibility (it is essentially a modified PostgreSQL backend). TiDB's architecture introduces operational complexity: administrators must manage two distinct services (TiDB servers and TiKV/TiFlash nodes) instead of one. The database also uses range-based sharding (called "regions") that can become unbalanced under certain access patterns, requiring manual intervention or placement rule tuning. In geo-distributed deployments, TiDB's P99 write latency (30-80ms) is lower than CockroachDB's (50-100ms) but still significantly higher than a single-region deployment, which may be a concern for latency-sensitive applications.
The honest trade-offs are clear. TiDB's layered architecture gives it flexibility and HTAP capability but at the cost of operational complexity. The MySQL compatibility is a double-edged sword: it eases migration but means TiDB inherits some MySQL limitations, such as less sophisticated query optimizer statistics compared to PostgreSQL-based systems. The free Starter tier is generous for evaluation but severely limited for production use (25 GiB storage, no multi-region, no backups). For small deployments (under a few hundred GB), TiDB is overkill — a single-node MySQL or PostgreSQL instance will be simpler and cheaper. The database also has a steeper learning curve for operators unfamiliar with distributed systems, particularly around placement rules, region management, and TiFlash configuration. On the positive side, TiDB's HTAP capability is genuinely unique among distributed SQL databases, and its throughput numbers are competitive or better than alternatives in most benchmarks. Organizations that need to scale MySQL workloads horizontally while adding real-time analytics without a separate system will find TiDB compelling, but they must accept the operational overhead and higher cost at smaller scales.
How it works
-
Distributed SQL architecture
Separates compute (TiDB) from storage (TiKV/TiFlash) for independent scaling, using Raft consensus for replication and fault tolerance.
-
MySQL wire protocol compatibility
Supports MySQL SQL dialect and wire protocol, allowing many existing MySQL applications to connect with minimal code changes.
-
HTAP (hybrid transactional/analytical processing)
Runs OLTP and real-time OLAP on the same cluster via TiFlash columnar storage, eliminating ETL pipelines for analytics.
-
Horizontal scalability
Adds nodes to scale out storage and compute independently; automatic region-based sharding rebalances data as nodes join or leave.
-
Strong ACID consistency
Provides full ACID transactions across multiple nodes using Raft consensus and distributed commit protocols.
-
Placement rules for data locality
Pins Raft leaders or data replicas to specific regions or nodes to reduce write latency and meet compliance requirements.
-
TiFlash columnar analytics engine
Asynchronously replicates data from TiKV to columnar storage, enabling sub-second analytical queries on fresh transactional data.
Strengths and trade-offs
Strengths
- Achieves 52K TPS on OLTP mixed workloads in independent benchmarks on c5.4xlarge instances across three regions, outperforming CockroachDB (45K TPS) and YugabyteDB (48K TPS).
- Real-time analytics capability is rated 'Excellent' in the same benchmarks, significantly ahead of CockroachDB and YugabyteDB, due to TiFlash's columnar engine.
- P99 write latencies of 30-80ms in geo-distributed deployments, lower than CockroachDB (50-100ms) and competitive with YugabyteDB.
- MySQL wire protocol compatibility enables straightforward migration for existing MySQL applications without rewriting SQL or changing drivers.
Trade-offs
- Operational complexity is higher than CockroachDB because administrators must manage two separate services (TiDB servers and TiKV/TiFlash nodes) instead of a single monolithic process.
- Range-based sharding (regions) can become unbalanced under skewed access patterns, requiring manual tuning of placement rules or region splitting.
- Free Starter tier is limited to 25 GiB row storage and 25 GiB column storage, making it unsuitable for production workloads beyond small-scale testing.
- For deployments under a few hundred GB, TiDB's distributed architecture is overkill; a single-node MySQL instance is simpler, cheaper, and easier to operate.
Pricing context
Free Starter tier ($0/month, 25 GiB row + 25 GiB column + 2 vCPU). Dedicated tier: per-minute billing for compute nodes, starting at $0.4416/hour for 4 vCPU TiDB node (us-west-2, AWS). TiKV nodes from $0.4416/hour (4 vCPU) to $3.5328/hour (32 vCPU).
TiFlash nodes from $1.3708/hour (8 vCPU) to $4.6368/hour (32 vCPU). TiProxy small $0.1955/hour, large $0.7820/hour. Prices vary by cloud provider and region.
Getting started with TiDB
-
Sign up for TiDB Cloud
Go to tidbcloud.com and create a free account. Select the Starter tier to get a cluster with 25 GiB row storage, 25 GiB column storage, and 2 vCPU at no cost. Verify your email to activate the account.
-
Connect your application
In the TiDB Cloud console, open the cluster overview and copy the connection string. Use a MySQL client or driver (e.g., mysql CLI, JDBC, or Python mysql-connector) to connect to the provided host, port, and user credentials.
-
Create a database and table
Run CREATE DATABASE your_db; and USE your_db;. Then execute CREATE TABLE orders (id INT PRIMARY KEY, customer VARCHAR(100), amount DECIMAL(10,2), created_at TIMESTAMP); to define a simple schema compatible with MySQL syntax.
-
Insert and query transactional data
Insert sample rows with INSERT INTO orders VALUES (1, 'Acme Corp', 250.00, NOW());. Run SELECT * FROM orders WHERE amount > 100; to verify read and write operations. TiDB handles these as distributed ACID transactions.
-
Run an analytical query with TiFlash
Enable TiFlash replication for the orders table by executing ALTER TABLE orders SET TIFLASH REPLICA 1;. After replication, run SELECT customer, SUM(amount) FROM orders GROUP BY customer; to see columnar acceleration for real-time analytics.
Frequently Asked Questions
What is TiDB and how does it work?
TiDB is an open-source distributed SQL database that separates compute from storage. It uses TiDB servers for SQL parsing, TiKV for row storage, and TiFlash for columnar analytics. Raft consensus ensures replication and fault tolerance across nodes.
Is TiDB compatible with MySQL?
Yes, TiDB is fully compatible with the MySQL wire protocol and SQL dialect. Existing MySQL applications can often connect with minimal code changes, making migration straightforward for teams with MySQL expertise or existing MySQL workloads.
What is TiDB's HTAP capability?
TiDB's HTAP design lets you run real-time analytics directly on fresh transactional data without ETL pipelines. The TiFlash columnar engine replicates data asynchronously from TiKV, enabling sub-second analytical queries on the same cluster handling OLTP writes.
How does TiDB perform in benchmarks?
In independent benchmarks on c5.4xlarge instances across three regions, TiDB achieved 52K TPS on OLTP mixed workloads, 95K QPS on read-heavy patterns, and P99 write latencies of 30-80ms. Its real-time analytics is rated Excellent, ahead of CockroachDB and YugabyteDB.
What is TiDB Cloud pricing?
TiDB Cloud offers a free Starter tier with 25 GiB row and column storage plus 2 vCPU. The Dedicated tier starts at $0.4416/hour for a 4 vCPU TiDB node on AWS us-west-2. TiKV and TiFlash nodes are billed per minute, with prices varying by provider and region.
What are the trade-offs of using TiDB?
TiDB's layered architecture provides flexibility and HTAP but adds operational complexity, requiring management of separate TiDB and TiKV/TiFlash services. Range-based sharding can become unbalanced under skewed access patterns, and the free tier is limited to 25 GiB storage, unsuitable for production.
Alternatives
How TiDB compares
Direct head-to-head against 3 competitors. Picked by 7wData.
TiDB
- Pricing
- Free Starter tier ($0/month, 25 GiB row + 25 GiB column + 2 vCPU). Dedicated tier: per-minute billing for compute nodes, starting at $0.4416/hour for 4 vCPU TiDB node (us-west-2, AWS). TiKV nodes from $0.4416/hour (4 vCPU) to $3.5328/hour (32 vCPU). TiFlash nodes from $1.3708/hour (8 vCPU) to $4.6368/hour (32 vCPU). TiProxy small $0.1955/hour, large $0.7820/hour. Prices vary by cloud provider and region.
- Target
- TiDB is an open-source distributed SQL database that combines a MySQL-compatible interface with horizontal scalability and strong ACID consistency across multiple nodes.
- Strength
- Achieves 52K TPS on OLTP mixed workloads in independent benchmarks on c5.4xlarge instances across three regions, outperforming CockroachDB (45K TPS) and YugabyteDB (48K TPS).
- Watch for
- Operational complexity is higher than CockroachDB because administrators must manage two separate services (TiDB servers and TiKV/TiFlash nodes) instead of a single monolithic process.
CockroachDB
- Pricing
- $1.50/node/hour (Serverless), $0.30/GB/month (Dedicated)
- Target
- PostgreSQL-compatible workloads needing global distribution
- Deployment
- Self-hosted or cloud
- Strength
- Strong consistency across regions
- Watch for
- Complex licensing for enterprise features
YugabyteDB
- Pricing
- Free tier, $0.25/vCPU/hour (Dedicated)
- Target
- PostgreSQL workloads with horizontal scaling
- Deployment
- Kubernetes-native
- Strength
- PostgreSQL API compatibility
- Watch for
- Limited HTAP capabilities vs TiDB
Amazon Aurora
- Pricing
- $0.12/vCPU/hour + $0.22/GB/month (MySQL-compatible)
- Target
- AWS-native MySQL/PostgreSQL workloads
- Deployment
- AWS only
- Strength
- Seamless AWS integration
- Watch for
- Write scaling limits at high throughput
User reviews
No user reviews yet. Be the first to write one.
Sources
Reporting on this tool draws on these publicly available sources.