Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's read-before-write in NoSQL?

I read in a book : "Cassandra is an NoSQL database and promotes read-before-write instead of relational model".

What does "read-before-write" means in a NoSQL context?

like image 995
Elyes Frikha Avatar asked Feb 27 '15 11:02

Elyes Frikha


Video Answer


1 Answers

Read before write means that you are checking the value of a cell before modifying it.

Read-Before write is a huge anti-pattern in Cassandra. Any book you read that encourages doing this should be looked at with suspicion. Normally Cassandra writes are performed without having any information about the current state of the database. One of the side effects of this is that all writes to Cassandra are actually update operations. This is allows for extremely fast writes but does have some limitations.

If you really need to check the state of the database before writing, Cassandra provides "Check and Set"(CAS) operations which use PAXOS to establish database state prior to modifying the record. These are written like update table set x = 3 if y = 1. CAS queries are orders of magnitude slower than a normal write in C* and should be used sparingly.

like image 147
RussS Avatar answered Sep 22 '22 08:09

RussS