Database / Apache Cassandra Intermediate and Advanced interview questions
What is a batch statement in Cassandra, and what's the difference between logged and unlogged batches?
A batch statement groups multiple CQL writes into a single request. Its main purpose is atomicity across statements, not performance.
| Logged Batch | Unlogged Batch |
| Default batch type; writes a batchlog entry first for atomicity. | Skips the batchlog; no atomicity guarantee across partitions. |
| Guarantees all statements eventually apply, even after a coordinator crash mid-batch. | Faster, but a crash mid-batch can leave some writes applied and others not. |
| Adds overhead: extra writes to the batchlog system table. | Best suited for statements that all target the same partition, where atomicity is naturally scoped anyway. |
BEGIN UNLOGGED BATCH INSERT INTO orders (order_id, status) VALUES ('o1', 'new'); INSERT INTO orders (order_id, status) VALUES ('o2', 'new'); APPLY BATCH;
Logged batches are appropriate when you genuinely need cross-partition atomicity (e.g. updating a record and a corresponding denormalized table together), while unlogged batches are best reserved for multiple writes to the same partition, where they can reduce round trips without sacrificing correctness.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
