# Modules Related to SQL Reads and Writes

![`smart`](ModulesSupportSQLOperations_aa_002_20220509.png)

-----------------------------------------------------------
As for the SQL reads and writes processes, we will introduce it in detail in the unit TiDB SQL Execution Flow. Here we briefly explain the role of the relevant modules.

`Executor` module
- After the execution plan generated by the `Compiler`, `Executor` executes the plan.

`DistSQL` module
- The `DistSQL` module is a layer of abstraction between TiDB server and Coprocessor. It encapsulates the lower Coprocessor request. The top-level SQL statement may contain complex operators such as joins and sub-queries, involving many tables, while `DistSQL` only deals with data from a single table. A `DistSQL` request can involves multiple Regions.

`TiKV Client` module
- It is mainly responsible for sending read and write requests to the TiKV. The first type is Raw KV request, which is a simple request to obtain a single row of data, such as an equivalent query based on a primary key index or a unique index. The second type is Coprocessor request, which requires that the computation also be pushed down to TiKV Coprocessor framework, such as filtering, aggregation, or column projection, etc.

`Transaction` module
- The processing of transaction is mainly done in this module, including two-phase commit, transaction pessimistic lock and optimistic lock management, etc.

`KV` module
- All transactional related request to TiKV is done by this KV module, for example, `KV Get` and `Batch Get`.

`PD Client` module
- This module is responsible for handling PD related requests.
