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
About the Author
About the Reviewers

Tracing Cassandra queries

Cassandra allows us to trace a query session; this can be used to debug queries that perform badly. On the cqlsh prompt, you can enable tracing using the command TRACING ON. After that, each query run on the prompt will be traced, and the trace output will be displayed.

Cassandra automatically saves a traced session in the system_traces keyspace. A saved session can be referenced later on for up to 24 hours.

Take the example of tracing an INSERT statement. Let's first create a column family with replication factor 1, as shown in the following example. We're taking a low replication factor for the simplicity of the example. In our example, is the coordinator node and is the replica node:

cqlsh> CREATE KEYSPACE userdb WITH replication = {'class': 'SimpleStrategy' , 'replication_factor': 1};
cqlsh> USE userdb ;
cqlsh:userdb> CREATE TABLE users ( userid text, address text, PRIMARY KEY(userid));
cqlsh:userdb> TRACING ON ;
Now Tracing...