Misuse of BATCH statements

One common anti-pattern when using batches is as follows:

BEGIN UNLOGGED BATCH   INSERT INTO "user_status_updates"     ("username", "id", "body")   VALUES(     'dave',     NOW(),     'dave update 5' );    INSERT INTO "user_status_updates"     ("username", "id", "body")   VALUES(     'ellen',     NOW(),     'ellen update 6' ); APPLY BATCH;

Since the batch update is performed on multiple partitions (dave and ellen), this has serious performance implications. Unlogged batches require the coordinator to do all the work of managing these inserts, and they will make a single node do more work. It's worse if the partition keys are owned by other nodes because then the coordinator node has an extra network hop to manage as well. The data is not ...

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.