Back to Toydb

SQL Engine

docs/architecture/sql.md

latest1.1 KB
Original Source

SQL Engine

The SQL engine provides support for the SQL query language, and is the main database interface. It uses a key/value store for data storage, MVCC for transactions, and Raft for replication. The SQL engine itself consists of several distinct components that form a pipeline:

Client → Session → Lexer → Parser → Planner → Optimizer → Executor → Storage

The SQL engine is located in the sql module. We'll discuss each of the components in a bottom-up manner.

The SQL engine is tested as a whole by test scripts under src/sql/testscripts. These typically take a raw SQL string as input, execute them against an in-memory storage engine, and output the result along with intermediate state such as the query plan, storage operations, and binary key/value data.


<p align="center"> ← <a href="raft.md">Raft Consensus</a> &nbsp; | &nbsp; <a href="sql-data.md">SQL Data Model</a> → </p>