pingcap / pingcap/tidb

Support stale read through SQL hints

Open
#59,938 1 comment 0 reactions 0 assignees View on GitHub
type/feature-request
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Feature Request

**Is your feature request related to a problem? Please describe:**

Stale read could be enabled by `tidb_read_staleness`, but it has some inconveniences, including:
- Using stale read `tidb_read_staleness` through session-level settings is very complicated, and the users may need to ensure that the session variable is set back after each use of stale read
- It also does not accept adding AS OF TIMESTAMP syntax to SQL to use stale read, which will cause the code to violate common coding rules and be bound to a certain feature of TiDB.

**Describe the feature you'd like:**

Introduce a new HINT to specify the tidb_read_staleness, makes TiDB specify the staleness in the statement, like
```
SELECT /*+ READ_STALENESS(-5) */ * FROM table1 WHERE ...
```
Or together with `SetVar`,
to support enabling query level stale read.

**Describe alternatives you've considered:**

As mentioned above for the usages of `tidb_read_staleness` and `AS OF TIMESTAMP`.

**Teachability, Documentation, Adoption, Migration Strategy:**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.