# Dml Writes Process Overview
__*DML Writes Process Overview*__

![left](./student-guide/diagram/DMLStatementWritesProcessOverview_aa_002_20220512.png)

------------------------------------------------------------
The process of writing a DML statement can be described as:

1. Received a SQL request from the client.

2. Asynchronously gets the start_ts of a SQL statement, that is, the TSO at which the SQL statement begins.

3. parse and compiles SQL statements and generates execution plans. (Parse, Compile)

4. Execution starts after querying the table metadata and region location information. (Execute)

5. TiKV receives a TiDB query request, executes it, filters it, and return it to the TiDB server.

6. The TiDB Server collates the received results.

7. TiDB Server performs a 2-phase commit, modify and persistes the data, and obtains the TSO at the time of commit, that is, commit_ts.

8. The TiDB Server return the result of writing data to the client.

Step 4 can be continued as follows:

1. Get the metadata of the table you want to query.

2. Generate key range information and get information about the regions where each key range is located.

3. Based on the location information of regions, TiDB Server sends a query request to TiKV where the region is located.

We can see that steps 1 to 6 are consistent with the read flow.

This diagram is a simplified process that will be explained in a later section.