lucius.pl
lucius.pl

Reputation: 65

Side effects of DELETE and INSERT in batch to modify primary key in Cassandra

What are side effects of operations DELETE and INSERT executed in batch to modify data in column, which is a member of primary key in Cassandra?

Is there a better approach if a query with WHERE and update data for the same column , are needed?

Thanks in advance for reply.

Upvotes: 2

Views: 666

Answers (1)

Chaity
Chaity

Reputation: 1388

There is no way to UPDATE a primary key column. You've to DELETE the old key and INSERT the new one (in a BATCH if atomicity is needed). If atomicity is not required (one statement does not impact the other), then you can execute as single request. As you are updating one row, INSERT and DELETE one row in a batch is fine. It'll not have great impact on performance. Deleting a large partition (there are too many rows per partition) will have impact and I think it is not your requirement either. But if you are needed to update your primary key quite frequently, then it is better to reconsider your data model.

Upvotes: 2

Related Questions