# Modules support SQL operations

![left](./student-guide/diagram/02-SQL-Reading-and-writing-related-modules-01-01.png)
------------------------------------------------------------
- Executor module
  - Execution will start according to the tree structure generated by Compile, and each layer will call the methods of the next layer to get the result.

- DistSQL module
  - In order to avoid coupling complex logic with the SQL layer, TiDB abstracts a unified distributed query interface layer, the DistSQL module.
      The DistSQL module is a layer of abstraction between the TiDB Server and the Coprocessor. It encapsulates the lower Coprocessor request to provide a simple select method for the upper layer. Performs a calculation task for a single table. The top-level SQL statement may contain complex operators such as JOIN and SUBQUERY, involving many tables, while DistSQL only involves data from a single table. A DistSQL request involves multiple regions, and we need to execute a coprocessor request for each region involved.

- TiKV Client module
  - It is mainly responsible for sending reads and writes requests to the TiKV module. The first is a raw KV request, which is a simple request to obtain a single row of data, for example, an equivalent query based on a primary key index or unique index, etc. The second type is a coprocessor request, which also needs to push the computation down to TiKV's coprocessor framework, such as filtering, aggregation, or column projection.

- Transaction module
  - Transaction processing is mainly done in this module, including two-stage commit, pessimistic lock/optimistic optimistic locking management, etc.

- KV module
  - Includes all transaction-related request to TiKV completed by this KV module, for example, kv get and batch get.

- PD Client module
  - This module is responsible for all PD-related request.














