Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the consistency level of an individual CQL query in CQL3?

In the earlier beta releases of CQL, there was a command I could use to set the read / write consistency of an individual CQL operation. It looked like this:

SELECT * FROM users WHERE state='TX' USING CONSISTENCY QUORUM;

I use CQL3 regularly and have a use-case where I need to be able to perform a read with a higher consistency level than the rest of our application.

I looked through the CQL3 reference and didn't find any mention of any CQL syntax that allows me to change the consistency settings on a per-query basis, unless I'm using cqlsh (not useful for application development.)

How am I supposed to tune the consistency on a per-request basis using CQL3?

like image 328
Aaronontheweb Avatar asked Jan 29 '14 21:01

Aaronontheweb


People also ask

How do you change the consistency level in Cassandra Query?

Tip: To set the consistency level of a lightweight transaction (LWT), use the SERIAL CONSISTENCY command. When using a LWT, you must have both a CONSISTENCY and a SERIAL CONSISTENCY level set. CONSISTENCY cannot be set to SERIAL or LOCAL_SERIAL, only SERIAL CONSISTENCY can be set to SERIAL or LOCAL_SERIAL.

How do you make Cassandra consistent?

Cassandra has tunable consistency with some tradeoffs you can choose. R + W > N - this simply means there must be one overlapping node in your roundtrip that has the actual and newest data available to be consistent. For example if you write at CL. ONE you will need to read at CL.

What is consistency level in Cassandra?

The Cassandra consistency level is defined as the minimum number of Cassandra nodes that must acknowledge a read or write operation before the operation can be considered successful. Different consistency levels can be assigned to different Edge keyspaces.


1 Answers

First set the consistency by running command:

CONSISTENCY QUORUM;

and then then run you query:

SELECT * FROM users WHERE state='TX'

At any point you can check the consistency using:

 CONSISTENCY;
like image 133
Chandan Avatar answered Sep 28 '22 01:09

Chandan