# Query Statement Process Overview

![`smart`](DMLStatementReadsProcessOverview_aa_007_20220512.png)

----------------------------------------------------------------
A query process can be briefly described as:

1. TiDB server receives a query request from the client program. (Protocol Layer)

2. TiDB server asynchronously gets the start_ts of the SQL statement, which is the TSO when the SQL statement starts.

3. TiDB server parses and compiles the SQL statement and generates the execution plan.

4. TiDB server checks the metadata of tables and the location information of Regions, then executes the statement.

5. TiKV server receives a query request from TiDB server, executes the command and filters data before returning the result to TiDB server.

6. TiDB server organizes the received results and returns them to the client program.

The fourth step can be further expanded to:

1. TiDB server gets the metadata of the table to be queried.

2. TiDB server generates key range information, and gets the Region information for each key range.

3. TiDB server sends query requests to the TiKV servers in parallel where the Regions are located according to the location information of the Regions.




