Apache Cassandra

Batch Operations: Logged vs Unlogged

Learn the correct use cases for CQL batches and why batching is not a general-purpose performance optimization in Cassandra.

CQL supports BATCH statements to group multiple INSERT, UPDATE, and DELETE operations together. However, unlike batches in relational databases, Cassandra batches are not primarily a performance optimization — in fact, misusing batches is one of the most common Cassandra anti-patterns among developers coming from SQL backgrounds.

A logged batch is like a courier who writes a receipt listing everything they promised to deliver before setting out, so if they get hit by a bus halfway through, someone else can finish the deliveries from that receipt. An unlogged batch is just handing the courier several packages at once with no such receipt — faster to hand off, but no guarantee they'll all get delivered if something goes wrong.

Key Concepts

1
A logged batch (the default) guarantees atomicity across all statements in the batch — either all mutations eventually apply, or none do — by first writing the batch to a distributed batchlog on two replicas before executing the individual statements. If the coordinator fails partway through, the batchlog is replayed to complete the batch. This atomicity guarantee is exactly why logged batches are the correct tool for keeping denormalized tables in sync (from query-first modeling).
logged batchbatchlog
2
An unlogged batch skips the batchlog step and simply sends all statements together without atomicity guarantees — it's really just a way to reduce network round trips when writing multiple unrelated rows, similar to a client-side pipeline.
unlogged batch
3
The key anti-pattern is using large batches (especially logged batches spanning many different partitions) purely to "batch up" unrelated writes for perceived efficiency — this actually increases coordinator load and batchlog overhead, hurting performance rather than helping it. Batches are most efficient and appropriate when all statements target the same partition.
same partition