You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/preview/reference/configuration/yb-tserver.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1812,6 +1812,24 @@ Default: 1024
1812
1812
1813
1813
Default: true
1814
1814
1815
+
##### yb_read_from_followers
1816
+
1817
+
Controls whether or not reading from followers is enabled. For more information, refer to [Follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/).
1818
+
1819
+
Default: false
1820
+
1821
+
##### yb_follower_read_staleness_ms
1822
+
1823
+
Sets the maximum allowable staleness. Although the default is recommended, you can set the staleness to a shorter value. The tradeoff is the shorter the staleness, the more likely some reads may be redirected to the leader if the follower isn't sufficiently caught up. You shouldn't set `yb_follower_read_staleness_ms` to less than 2x the `raft_heartbeat_interval_ms` (which by default is 500 ms).
1824
+
1825
+
Default: 30000 (30 seconds)
1826
+
1827
+
##### default_transaction_read_only
1828
+
1829
+
Turn this setting `ON/TRUE/1` to make all the transactions in the current session read-only. This is helpful when you want to run reports or set up [follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/#read-only-transaction).
1830
+
1831
+
Default: false
1832
+
1815
1833
##### default_transaction_isolation
1816
1834
1817
1835
Specifies the default isolation level of each new transaction. Every transaction has an isolation level of `read uncommitted`, `read committed`, `repeatable read`, or `serializable`.
Copy file name to clipboardExpand all lines: docs/content/stable/reference/configuration/yb-tserver.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1790,6 +1790,24 @@ Default: 1024
1790
1790
1791
1791
Default: true
1792
1792
1793
+
##### yb_read_from_followers
1794
+
1795
+
Controls whether or not reading from followers is enabled. For more information, refer to [Follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/).
1796
+
1797
+
Default: false
1798
+
1799
+
##### yb_follower_read_staleness_ms
1800
+
1801
+
Sets the maximum allowable staleness. Although the default is recommended, you can set the staleness to a shorter value. The tradeoff is the shorter the staleness, the more likely some reads may be redirected to the leader if the follower isn't sufficiently caught up. You shouldn't set `yb_follower_read_staleness_ms` to less than 2x the `raft_heartbeat_interval_ms` (which by default is 500 ms).
1802
+
1803
+
Default: 30000 (30 seconds)
1804
+
1805
+
##### default_transaction_read_only
1806
+
1807
+
Turn this setting `ON/TRUE/1` to make all the transactions in the current session read-only. This is helpful when you want to run reports or set up [follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/#read-only-transaction).
1808
+
1809
+
Default: false
1810
+
1793
1811
##### default_transaction_isolation
1794
1812
1795
1813
Specifies the default isolation level of each new transaction. Every transaction has an isolation level of `read uncommitted`, `read committed`, `repeatable read`, or `serializable`.
Copy file name to clipboardExpand all lines: docs/content/v2.18/reference/configuration/yb-tserver.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1226,6 +1226,24 @@ Default: `1GB`
1226
1226
1227
1227
Default: 1
1228
1228
1229
+
##### yb_read_from_followers
1230
+
1231
+
Controls whether or not reading from followers is enabled. For more information, refer to [Follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/).
1232
+
1233
+
Default: false
1234
+
1235
+
##### yb_follower_read_staleness_ms
1236
+
1237
+
Sets the maximum allowable staleness. Although the default is recommended, you can set the staleness to a shorter value. The tradeoff is the shorter the staleness, the more likely some reads may be redirected to the leader if the follower isn't sufficiently caught up. You shouldn't set`yb_follower_read_staleness_ms` to less than 2x the `raft_heartbeat_interval_ms` (which by default is 500 ms).
1238
+
1239
+
Default: 30000 (30 seconds)
1240
+
1241
+
##### default_transaction_read_only
1242
+
1243
+
Turn this setting `ON/TRUE/1` to make all the transactions in the current session read-only. This is helpful when you want to run reports orset up [follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/#read-only-transaction).
1244
+
1245
+
Default: false
1246
+
1229
1247
## Admin UI
1230
1248
1231
1249
The Admin UI for the YB-TServer is available at `http://localhost:9000`.
Copy file name to clipboardExpand all lines: docs/content/v2.20/reference/configuration/yb-tserver.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1404,6 +1404,24 @@ See also the [--ysql_yb_fetch_row_limit](#ysql-yb-fetch-row-limit) flag. If the
1404
1404
1405
1405
Default: 1024
1406
1406
1407
+
##### yb_read_from_followers
1408
+
1409
+
Controls whether or not reading from followers is enabled. For more information, refer to [Follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/).
1410
+
1411
+
Default: false
1412
+
1413
+
##### yb_follower_read_staleness_ms
1414
+
1415
+
Sets the maximum allowable staleness. Although the default is recommended, you can set the staleness to a shorter value. The tradeoff is the shorter the staleness, the more likely some reads may be redirected to the leader if the follower isn't sufficiently caught up. You shouldn't set`yb_follower_read_staleness_ms` to less than 2x the `raft_heartbeat_interval_ms` (which by default is 500 ms).
1416
+
1417
+
Default: 30000 (30 seconds)
1418
+
1419
+
##### default_transaction_read_only
1420
+
1421
+
Turn this setting `ON/TRUE/1` to make all the transactions in the current session read-only. This is helpful when you want to run reports orset up [follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/#read-only-transaction).
1422
+
1423
+
Default: false
1424
+
1407
1425
##### default_transaction_isolation
1408
1426
1409
1427
Specifies the default isolation level of each new transaction. Every transaction has an isolation level of `read uncommitted`, `read committed`, `repeatable read`, or`serializable`.
Copy file name to clipboardExpand all lines: docs/content/v2024.2/develop/learn/transactions/transactions-global-apps.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,8 +33,8 @@ In such scenarios, you can enable [follower reads](../../../../explore/going-bey
33
33
To enable follower reads, set the transaction to be [READ ONLY](../../../../api/ysql/the-sql-language/statements/txn_set/#read-only-mode) and turn on the YSQL parameter `yb_read_from_followers`. For example:
Copy file name to clipboardExpand all lines: docs/content/v2024.2/explore/going-beyond-sql/follower-reads-ysql.md
+49-34Lines changed: 49 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,9 @@ YugabyteDB requires reading from the leader to read the latest data. However, fo
17
17
18
18
## Use cases
19
19
20
-
1.**Time-critical** : Suppose the end-user starts a donation page to raise money for a personal cause and the target amount must be met by the end of the day. In a time-critical scenario, the end-user benefits from accessing the most recent donation made on the page and can keep track of the progress. Such real-time applications require the latest information as soon as it is available. But in the case of an application where fetching slightly stale data is acceptable, follower reads can be helpful.
20
+
1.**Time-critical**. Suppose the end-user starts a donation page to raise money for a personal cause and the target amount must be met by the end of the day. In a time-critical scenario, the end-user benefits from accessing the most recent donation made on the page and can keep track of the progress. Such real-time applications require the latest information as soon as it is available. But in the case of an application where fetching slightly stale data is acceptable, follower reads can be helpful.
21
21
22
-
1.**Latency-tolerant (staleness)** : Suppose a social media post gets a million likes and more continuously. For a post with massive likes such as this one, slightly stale reads are acceptable, and immediate updates are not necessary because the absolute number may not really matter to the end-user reading the post. Such applications do not need to always make requests directly to the leader. Instead, a slightly older value from the closest replica can achieve improved performance with lower latency.
22
+
1.**Latency-tolerant (staleness)**. Suppose a social media post gets a million likes and more continuously. For a post with massive likes such as this one, slightly stale reads are acceptable, and immediate updates are not necessary because the absolute number may not really matter to the end-user reading the post. Such applications do not need to always make requests directly to the leader. Instead, a slightly older value from the closest replica can achieve improved performance with lower latency.
23
23
24
24
Follower reads are applicable for applications that can tolerate staleness. Replicas may not be completely up-to-date with all updates, so this design may respond with stale data. You can specify how much staleness the application can tolerate. When enabled, read-only operations may be handled by the closest replica, instead of having to go to the leader.
25
25
@@ -56,8 +56,8 @@ The following table provides information on the expected behavior when a read ha
56
56
57
57
You can mark a transaction as read-only by applying the following guidelines:
58
58
59
-
-`SET TRANSACTION READ ONLY` applies only to the current transaction block.
60
-
-`SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY` applies the read-only setting to all statements and transaction blocks that follow.
59
+
- SET TRANSACTION READ ONLY applies only to the current transaction block.
60
+
- SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY applies the read-only setting to all statements and transaction blocks that follow.
61
61
-`SET default_transaction_read_only = TRUE` applies the read-only setting to all statements and transaction blocks that follow.
62
62
63
63
Note: The use of `pg_hint_plan` to mark a statement as read-only is not recommended. It may work in some cases, but relies on side effects and has known issues (see [GH17024](https://github.com/yugabyte/yugabyte-db/issues/17024) and [GH17135](https://github.com/yugabyte/yugabyte-db/issues/17135)).
@@ -68,16 +68,31 @@ Note: The use of `pg_hint_plan` to mark a statement as read-only is not recommen
68
68
69
69
- If the follower is not yet caught up to `<current_time> - <staleness>`, the read is redirected to a different replica transparently from the end-user. The end-user may see a slight increase in latency depending on the location of the replica which satisfies the read.
70
70
71
-
72
71
## Examples
73
72
74
73
This example uses follower reads because the transaction is marked read-only:
75
74
76
75
```sql
77
-
set yb_read_from_followers = true;
78
-
start transaction read only;
79
-
SELECT*from t WHERE k='k1';
80
-
commit;
76
+
SET yb_read_from_followers = true;
77
+
START TRANSACTION READ ONLY;
78
+
SELECT*FROM t WHERE k='k1';
79
+
COMMIT;
80
+
SET yb_read_from_followers = false;
81
+
```
82
+
83
+
```output
84
+
k | v
85
+
----+----
86
+
k1 | v1
87
+
```
88
+
89
+
Use SET LOCAL inside a transaction to have follower reads turned on only for the transaction. Set `yb_read_from_followers` before any statement is executed in the block:
90
+
91
+
```sql
92
+
START TRANSACTION READ ONLY;
93
+
SET LOCAL yb_read_from_followers = true;
94
+
SELECT*FROM t WHERE k='k1';
95
+
COMMIT;
81
96
```
82
97
83
98
```output
@@ -89,9 +104,9 @@ commit;
89
104
This example uses follower reads because the session is marked read-only:
90
105
91
106
```sql
92
-
set session characteristics as transaction read only;
93
-
set yb_read_from_followers = true;
94
-
SELECT*from t WHERE k='k1';
107
+
SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
108
+
SET yb_read_from_followers = true;
109
+
SELECT*FROM t WHERE k='k1';
95
110
```
96
111
97
112
```output
@@ -101,16 +116,16 @@ SELECT * from t WHERE k='k1';
101
116
(1 row)
102
117
```
103
118
104
-
The following is a `JOIN` example that uses follower reads:
119
+
The following is a JOIN example that uses follower reads:
Copy file name to clipboardExpand all lines: docs/content/v2024.2/reference/configuration/yb-tserver.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1812,6 +1812,24 @@ Default: 1024
1812
1812
1813
1813
Default: true
1814
1814
1815
+
##### yb_read_from_followers
1816
+
1817
+
Controls whether or not reading from followers is enabled. For more information, refer to [Follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/).
1818
+
1819
+
Default: false
1820
+
1821
+
##### yb_follower_read_staleness_ms
1822
+
1823
+
Sets the maximum allowable staleness. Although the default is recommended, you can set the staleness to a shorter value. The tradeoff is the shorter the staleness, the more likely some reads may be redirected to the leader if the follower isn't sufficiently caught up. You shouldn't set `yb_follower_read_staleness_ms` to less than 2x the `raft_heartbeat_interval_ms` (which by default is 500 ms).
1824
+
1825
+
Default: 30000 (30 seconds)
1826
+
1827
+
##### default_transaction_read_only
1828
+
1829
+
Turn this setting `ON/TRUE/1` to make all the transactions in the current session read-only. This is helpful when you want to run reports or set up [follower reads](../../../explore/going-beyond-sql/follower-reads-ysql/#read-only-transaction).
1830
+
1831
+
Default: false
1832
+
1815
1833
##### default_transaction_isolation
1816
1834
1817
1835
Specifies the default isolation level of each new transaction. Every transaction has an isolation level of `read uncommitted`, `read committed`, `repeatable read`, or `serializable`.
0 commit comments