简体   繁体   中英

Cassandra range queries cql

I have to create a table which stores a big amount of data (like 400 columns and 5.000.000 to 40.000.000 rows). There is a counter "counter" which counts from 1 upwards. Right now this is my primary key. The other variables are int, float, and varchar type and repeating.

I need to do this for a database-comparison, so I have to use Cassandra, even if there could be other databases, that can do better in this specific problem.

On this table I want to execute some range queries. The queries should be like:

SELECT counter, val1, val2, val3 FROM table WHERE counter > 1000 AND counter < 5000;

Also there will be other filter-parameters:

... AND val54 = 'OK';

I think this is a problem in Cassandra, because "counter" is the PK. I will try running the token() function, but I guess this will be slow.

Right now I am learning about the data modelling in Cassandra but I hope somebody with experience in Cassandra got some hints for me, like how to organize the table and make the queries possible and fast? Perhaps just some topics I should learn about or links that will help me.

Have a nice day, Friedrich

This sounds like a bad use case for Cassandra.

First, range queries are discouraged in Cassandra. This is because the range can't be resolved with out visiting every node in the cluster.

Second, you can't mix a counter type column with other column types. For a given table it can either have (and only have) counter columns or it can have all non-counter columns.

As far as Cassandra data modeling goes, if you want to create a successful data model, create your partitions around the exact thing you're going to query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM