Open-Source Wikis

/

TiDB

/

TiDB

pingcap/tidb

TiDB

TiDB is an open-source, distributed SQL database written in Go. It speaks the MySQL 8.0 wire protocol, stores data in a horizontally scalable key-value layer (TiKV) with Raft replication, and supports both transactional (OLTP) and analytical (HTAP via TiFlash) workloads from the same data.

This repository (github.com/pingcap/tidb) contains the TiDB SQL layer: the parser, planner/optimizer, execution engine, schema and DDL machinery, session and protocol handling, statistics, and the storage client that talks to TiKV/PD. It also hosts several first-party CLI tools that ship alongside the database server: BR (backup & restore), Lightning (bulk data import), and Dumpling (logical export).

What this repo contains

  • cmd/tidb-server/ — the TiDB SQL server entry point (main.go).
  • pkg/ — the bulk of the database. Parser, planner, executor, expression engine, DDL, infoschema, sessions, statistics, storage client, server (MySQL protocol), domain (metadata cache and lifecycle), and a large util/ tree.
  • br/ — Backup & Restore tool and library.
  • lightning/ — TiDB Lightning (high-throughput SQL/CSV import).
  • dumpling/ — Dumpling (logical SQL/CSV dump tool).
  • tests/ — integration and real-TiKV test harnesses (integrationtest, realtikvtest, clusterintegrationtest, globalkilltest, …).
  • docs/ — architecture index, agent runbooks, and design docs.
  • tools/ — repo tooling (e.g., tools/check, tools/tazel, tools/patch-go).

Where to start reading

Where TiDB fits

A TiDB cluster has three core components:

  • TiDB server (this repo): stateless SQL frontend.
  • TiKV: distributed transactional KV store (separate repo: tikv/tikv).
  • PD (Placement Driver): cluster metadata, region/leader scheduling, timestamp oracle (separate repo: tikv/pd).

Optionally, TiFlash provides a columnar replica for HTAP workloads. The TiDB server in this repo connects to TiKV and PD through the tikv/client-go/v2 Go client (see pkg/store/driver/), and to TiFlash through MPP coprocessor RPCs (see pkg/store/copr/).

License and project home

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

TiDB – TiDB wiki | Factory