Does a regular (non-transactional) SQL read require obtaining a TSO?

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

Original topic: 普通(非事务)SQL读取需要获取TSO吗?

| username: alfred

【TiDB Usage Environment】Production, Testing, Research
【TiDB Version】
【Encountered Problem】
【Reproduction Path】What operations were performed that led to the problem
【Problem Phenomenon and Impact】

【Attachments】

Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.

| username: cheng | Original post link

Isn’t a regular SQL also a transaction? The only difference is one is auto-commit and the other is manual commit. Both require obtaining TSO.

| username: alfred | Original post link

Ordinary select

| username: cheng | Original post link

A regular select is also a transaction and requires obtaining a TSO.

| username: HACK | Original post link

Point queries should not require TSO, others require TSO.

| username: alfred | Original post link

If it’s similar to Oracle’s SCN, a regular select will also cause the SCN to increase.

| username: alfred | Original post link

Does anyone know?

| username: forever | Original post link

At the beginning of a transaction, TiDB obtains a TSO as start_ts, and at the time of commit, it obtains a TSO as commit_ts. It relies on TSO to implement MVCC for transactions. For queries, MVCC requests TSO once, while for writes, it requests TSO twice. The TSO timestamp service ensures that timestamps are allocated in an increasing manner, and any timestamp obtained from a request will not be duplicated.

| username: alfred | Original post link

That means any query requires obtaining a TSO, because MVCC also relies on TSO.

| username: forever | Original post link

Yes, otherwise how can consistency be achieved?

| username: h5n1 | Original post link

Any transaction (explicit or implicit) needs to obtain a TSO. Generally speaking, it starts with a start TSO, commits with a commit TSO, and pessimistic DML also has a for update TSO. The RC isolation level requires each SQL to obtain a TSO.

| username: alfred | Original post link

The RC isolation level requires each SQL to obtain a TSO. What about the RR isolation level?

| username: yilong | Original post link

It should have nothing to do with the isolation level; the transaction needs to obtain TSO when reading.

| username: wuxiangdong | Original post link

Need to obtain MVCC.