0

I'm new to Cassandra and I come from a relational world. When I was playing with CQL I observed that I didn't find any difference. For ex:

when I execute below query

update product set price=100, currency=USD where productID=12345;

then CQL creates new row in the table. In RDBMS this won't work since there is no product with productID = 12345.

Can you provide some insight ?

ak123
  • 285
  • 2
  • 5
  • 15

1 Answers1

1

What you've discovered is that most Cassandra writes (with a few exceptions) do writes without reads. There are a number of reasons for this - one is performance (reading first is slow), but also consider that the first INSERT may have happened on another server, and not yet replicated to the server processing the UPDATE.

What you're really saying is "set the price to $100USD for product 12345". If no such product exists (yet?), it's still setting the price, because it's not going to take the time to find out if the product exists.

If you need to check if the row exists, Cassandra provides a paxos implementation for lightweight transactions ( http://www.datastax.com/dev/blog/lightweight-transactions-in-cassandra-2-0 ) that can provide some IF [NOT EXISTS] type logic for you (at a significant performance penalty).

Jeff Jirsa
  • 4,391
  • 11
  • 24