This topic describes the best practices for weak-consistency reads in OceanBase AI Database.
For batch or statistical applications with low real-time requirements, you can set weak-consistency reads to avoid impacting the primary replica. Configure a session-level setting or use a weak-consistency read hint to offload read operations to a standby replica:
Added hints for SELECT queries
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 read requests 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)