Search code examples
couchbaseconsistency

What exactly is the difference between REQUEST_PLUS and STATEMENT_PLUS ScanConsistency in Couchbase?


I couldn't understand the different between a request and a statement and how consistency is related to each of them.


Solution

    • RequestPlus ensures all documents at the time of the query have been indexed.
    • AtPlus (or StatementPlus) ensures that the specified documents have been indexed.
      • This allows for Read Your Own Write without delaying for other writes.

    For example:

    1. Bucket B contains one document.
    2. SELECT COUNT(1) FROM B -> result is 1.
    3. You insert a document with ID a
    4. Another document is inserted with ID b
    5. SELECT COUNT(1) FROM B
      • With "Not Bounded" (default) consistency -> immediate result of at least 1 is returned.
      • With "AtPlus" consistency, specifying additional state that a was mutated -> result of at least 2 after document a is updated in the index.
      • With "RequestPlus" consistency -> result of 3 after indexing has completely caught up.