There are cases when it is necessary to modify data based on its current state: that is, to perform an update that is executed only if a row does not exist or contains a certain value. Lightweight Transactions (LWTs) provide this functionality by only allowing changes to data to occur if the condition provided evaluates as true. The conditional statements provide linearizable semantics, thus allowing data to remain consistent. A basic rule of thumb is that any statement with an IF clause is a conditional statement. A batch that has at least one conditional statement is a conditional batch. Conditional statements and conditional batches are executed atomically as a LWT. This lesson provides an overview of LWT, an example of how it’s used, and a comparison with Apache Cassandra.
Some of the topics covered in this lesson are:
- An overview of LWT, how to use, and some common use cases with an example
- LWT performance, for different use cases, also compared to Apache Cassandra LWT
- LWT under the hood: how is LWT implemented in ScyllaDB? What are some of the caveats, and what are the tradeoffs of using LWT
For more information about LWT, you can also read the documentation and this blog post.