17

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?

Aaronontheweb
  • 8,224
  • 6
  • 32
  • 61

3 Answers3

23

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;
Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Chandan
  • 3,349
  • 2
  • 22
  • 18
9

Aaron, the Consistency Level is not needed to be set on the protocol level - for the reasons explained here: https://issues.apache.org/jira/browse/CASSANDRA-4734

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Roman Tumaykin
  • 1,921
  • 11
  • 11
  • 5
    Specifically this means that the driver you are using will tell you how to set it's consistency level. – RussS Jan 30 '14 at 00:13
5

The default consistency level for any query is "ONE". However, one can set the consistency level on query basis as below. Setting Consistency Level

Based on the Replication factor, the location of the partition (nodes list) can be found as below.

nodetool getendpoints Keyspace-name table-name partition-key value

$ nodetool getendpoints stresstest status bill
10.134.38.15
10.134.38.24
10.134.38.26
Arun
  • 1,692
  • 15
  • 24