INSERT
and UPDATE
in CQL are the same call under the covers, because on the storage layer, you only really have updates anyway. In CQL, INSERT
and UPDATE
are exposed as syntactic sugar to make CQL feel more like SQL. There are slight nuances, such as the UPDATE
statement taking a WHERE
clause and also being used to increment counter tables, but they don't really affect the underlying PUT semantics when CQL is translated to the storage layer.
IF NOT EXISTS
used with an INSERT
or IF
used with an UPDATE
in CQL tells Cassandra to execute a compare and swap operation on the backend. This means that the operation will only get executed if the pre-condition is met. This requires consensus, so in a distributed setting (e.g. more than 1 Cassandra node), this might incur a performance penalty.
So given this, I don't think that this mirrors the SQL MERGE behavior. The thing that it does have in common is that both variants require the server to acquire a row lock in order to perform the operation atomically.