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

Aaronontheweb picture Aaronontheweb · Jan 29, 2014 · Viewed 31.4k times · Source

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?

Answer

Chandan picture Chandan · Jun 26, 2015

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;