Reputation: 3229
I have a table in my Cassandra DB with columns userid, city1, city2 and city3. What would my query be if I wanted to retrieve all users that have "Paris" as a city? I understand Cassandra doesn't have OR so I'm not sure how to structure the query.
Upvotes: 0
Views: 33
Reputation: 87109
First - it's heavily depend on the structure of the table - if you have userid
as partition key, you can of course use secondary index to search users in cities, but it's not optimal as it's fan-out call - request is sent to all nodes in the cluster. You can re-design to use the materialized view with city as partition key, but you may have problems if you have a lot users in some cities.
In general, if you need to select several values in the same column - you can use IN
operator, but it's better not to use it for partition keys (parallel queries are better). If you need OR
on different columns - you need to do parallel queries, and collect results on application side.
Upvotes: 1