# Dml Statement Writes Process Overview


![left](./student-guide/diagram/05-Write-process-01-01.png)

------------------------------------------------------------
The process of writing a DML statement can be described as:
  - Received a SQL request from the client.
  - Asynchronously get the start_ts of the SQL statement, that is, the TSO at the start of the SQL statement.
  - Parse and compile SQL statements and generate execution plans. (Parse, Compile)
  - Execution starts after querying the table metadata and location information of the region. (Execute)
  - TiKV receives a query request from TiDB, executes it, and filters it and return it to the TiDB server.
  - The results received by TiDB Server are collated.
  - TiDB Server performs a 2-phase commit, modify the data and persists it, and obtains the TSO at the time of submission, i.e. commit_ts.
  - TiDB Server return the result of writing data to the client.

Step 4 of these can continue to expand to:
  - Get the metadata of the table you want to query.
  - Generate key range information and get the region information for each key range.
  - TiDB Server sends a query request to the TiKV in the region based on the location information of the region.

We can see that steps 1 to 6 are consistent with the reading process.
This diagram is a simplified process that will be expanded in a later section.
