Book Image

Apache Cassandra Essentials

By : Nitin Padalia
Book Image

Apache Cassandra Essentials

By: Nitin Padalia

Overview of this book

Apache Cassandra Essentials takes you step-by-step from from the basics of installation to advanced installation options and database design techniques. It gives you all the information you need to effectively design a well distributed and high performance database. You’ll get to know about the steps that are performed by a Cassandra node when you execute a read/write query, which is essential to properly maintain of a Cassandra cluster and to debug any issues. Next, you’ll discover how to integrate a Cassandra driver in your applications and perform read/write operations. Finally, you’ll learn about the various tools provided by Cassandra for serviceability aspects such as logging, metrics, backup, and recovery.
Table of Contents (14 chapters)
Apache Cassandra Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Batch statements


Cassandra supports the execution of multiple INSERT / UPDATE / DELETE operations in a batch. This way, client programs can save the time it takes to send queries multiple times to the server. In versions above 1.2, default batch statements are atomic. This means either all the statements of a batch will be completed or none will. Statements inside a batch are not isolated. So, if a batch is being executed and has completed some of the statements inside it, then a parallel running client can read those changes. However, updates belonging to a partition key are isolated:

BEGIN BATCH
INSERT INTO cars (brand, model, variant , body_type, colors, mileage) VALUES ( 'Audi', 'Q1', '3.0 TDI QUATTRO', 'Sedan', {'Apple Green', 'Titanium Black'},
14.2);
UPDATE cars SET body_type = 'Sedan' WHERE brand='Audi' AND model ='Q7' AND variant = '3.0 TDI QUATTRO PREMIUM PLUS';
APPLY BATCH;

Atomicity comes at some performance cost. To avoid it, UNLOGGED batches could be used. These batches will...