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, 10.78.171.11 is the coordinator node and 10.78.171.12 is the replica node:

cqlsh> ...

Get Apache Cassandra Essentials 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.