TinySQL is a comprehensive course designed to teach you how to implement a distributed relational database in Go. The name TinySQL indicates it is a simplified version of TiDB.
- Experience with Go is required. If not, it is recommended to learn A Tour of Go first.
- Basic understanding of database concepts and SQL
- Familiarity with distributed systems concepts (recommended)
The course combines theoretical understanding through source code reading with hands-on implementation projects. Each module includes both learning materials and practical projects.
- Architecture Overview Reading
- Processing Flow Reading
- SQL and Parser
- Parser Implementation Reading
- Project: SQL Parser Implementation
- Project: SQL Foundations Implementation
- Query Execution
- Select Statement Processing Reading
- Project: Query Executor Implementation
- Query Optimization
- Logical Optimization Reading
- Cost-based Optimization Reading
- Advanced Optimization Reading
- Project: Query Optimizer Implementation
- Join Operations
- Storage Structures
- Statistics and Optimization
- Data Organization
- Table Partitioning Reading
- Project: Table Storage Implementation
- DDL Operations
- DDL Implementation Reading
- Project: DDL Implementation Implementation
- Transaction Processing
- Project: Percolator Transaction Implementation
- TiKV Integration
- Additional Features
TinySQL follows a distributed SQL architecture similar to TiDB:
- Protocol Layer: MySQL protocol support
- SQL Layer: Parser, Optimizer, Executor
- KV Layer: Distributed storage interface
make
-
Standalone Mode:
./bin/tidb-server mysql -h127.0.0.1 -P4000 -uroot
-
Cluster Mode (with TinyKV):
mkdir -p data ./tinyscheduler-server ./tinykv-server -path=data ./tidb-server --store=tikv --path="127.0.0.1:2379"
- TinyKV - The distributed KV storage implementation course
Contributions are welcome! Please read our contributing guidelines before submitting pull requests.
TinySQL is under the Apache 2.0 license. See the LICENSE file for details.