This topic describes how to perform read operations with eventual consistency in OceanBase Database.
For applications that do not require real-time data, such as batch or statistical applications, you can configure weak consistency reads to avoid impacting 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)