How do secondary indexes work in Cassandra?

select * from update_audit where scopeid=35 and formid=78005 and record_link_id=9897; How the above query will work internally in cassandra? Essentially, all data for partition scopeid=35 and formid=78005 will be returned, and then filtered by the record_link_id index. It will look for the record_link_id entry for 9897, and attempt to match-up entries that match the rows … Read more

Cassandra cqlsh – how to show microseconds/milliseconds for timestamp columns?

In an effort to answer your questions, I did a little digging on this one. Does Cassandra capture microseconds with timestamp data type? Microseconds no, milliseconds yes. If I create your table, insert a row, and try to query it by the truncated time, it doesn’t work: aploetz@cqlsh:stackoverflow> INSERT INTO data (datetime, id, type, data) … Read more

Cassandra cqlsh – connection refused

You need to edit cassandra.yaml on the node you are trying to connect to and set the node ip address for rpc_address and listen_address and restart Cassandra. rpc_address is the address on which Cassandra listens to the client calls. listen_address is the address on which Cassandra listens to the other Cassandra nodes.

How to create auto increment IDs in Cassandra

How about the following, using Cassandra’s Lightweight transactions 1 – Create IDs table: CREATE TABLE ids ( id_name varchar, next_id int, PRIMARY KEY (id_name) ) 2 – Insert every id you’d like to use a global sequence with For example: INSERT INTO ids (id_name, next_id) VALUES (‘person_id’, 1) 3 – Then, when inserting to a … Read more

Inner Join in cassandra CQL

Because of its distributed nature, Cassandra has no support for RDBMS style joins. You have a few options for when you want something like a join. One option perform separate queries and then have your application join the data itself. This makes sense if the data is relatively small and you only have to perform … Read more

cassandra get all records in time range

The timeout is because Cassandra is taking longer than the timeout (default is 10 seconds) to return the data. For your query, Cassandra will attempt to fetch the entire dataset before returning. For more than a few records this can easily take longer than the timeout. For queries that are producing lots of data you … Read more