Why does a transaction need both start_ts and commit_ts timestamps?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 为什么一个事务需要start_ts和commit_ts两个时间戳呢?

| username: TiDBer_9WPt1wx3

During the execution of a transaction, two timestamps need to be obtained from PD. The start_ts is used to determine which version of the data to read, and the commit_ts is used to update the version of the written data.

I would like to ask what is the necessity of commit_ts, and why not directly use start_ts to update the version of the written data?

| username: xfworld | Original post link

commit_ts is used for concurrency processing to compare which submitted data is newer.

start_ts is used to read data at a certain point in time. According to the understanding of MVCC, each piece of data will be different at different points in time, so a specific version must be specified…

I suggest you read the TiDB transaction-related content:

| username: 特雷西-迈克-格雷迪 | Original post link

start_ts and commit_ts are both for MVCC version comparison and the implementation of isolation levels.

| username: 张雨齐0720 | Original post link

Understanding the principles of MVCC will help you understand why two timestamps are needed.