This topic describes how to perform weak-consistency reads in OceanBase Database.
For applications that do not require high real-time performance, such as batch processing and statistical analysis, you can enable weak-consistency reads to avoid affecting the primary replica. You can configure session-level or weak-consistency read hints to execute read operations on the standby replica:
Add a hint to a SELECT statement.
SELECT /*+read_consistency(weak)*/ * FROM test WHERE c1=1;Set the system variable at the session level (1=FROZEN, 2=WEAK, 3=STRONG).
SET @@ob_read_consistency= 2;Weak-consistency reads are supported when the isolation level is set to REPEATABLE READ or SERIALIZABLE. Example:
obclient> SET transaction read only; Query OK, 0 rows affected (0.001 sec) obclient> SELECT /*+ read_consistency(weak)*/ * FROM t WHERE a=2; +------+------+ | ID | A | +------+------+ | NULL | 2 | +------+------+ 1 row in set (0.001 sec)
