cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peddi, Praveen" <>
Subject Re: Ordering by multiple columns?
Date Mon, 10 Oct 2016 22:25:12 GMT
That's not just a bad idea but that's impossible. Any field that is part of primary key is
immutable. You should read up the Cassandra documentation and understand the basics before
start using it. Otherwise you could easily abuse it inadvertently.


On Oct 10, 2016, at 6:22 PM, Ali Akhtar <<>>

E.g if I wanted to select * from foo where last_updated <= ?

In this case, (I believe) last_updated will have to be a clustering key. If the record got
updated and I wanted to update last_updated accordingly, that's a bad idea?


On Tue, Oct 11, 2016 at 3:19 AM, Ali Akhtar <<>>
Huh - So if I wanted to search / filter by a timestamp field, and this timestamp needed to
get updated, that won't be possible?

On Tue, Oct 11, 2016 at 3:07 AM, Nicolas Douillet <<>>
If I correctly understand the answers, the solution to your ordering question is to use clustering
I'm agree, but I just wanted to warn you about one limitation :  the values of keys can't
be updated, unless by using a delete and then an insert.
(In the case of your song "example", putting the rate as a key can be tricky if the value
has to be frequently updated)

Le lun. 10 oct. 2016 ? 22:15, Mikhail Krupitskiy <<>>
a ?crit :
Looks like ordering by multiple columns in Cassandra has few sides that are not obvious.
I wasn't able to find this information in the official documentation but it's quite well described

On 10 Oct 2016, at 21:55, DuyHai Doan <<>>

No, we didn't record the talk this time unfortunately :(

On Mon, Oct 10, 2016 at 8:17 PM, Ali Akhtar <<>>
Really helpful slides. Is there a video to go with them?

On Sun, Oct 9, 2016 at 11:48 AM, DuyHai Doan <<>>
Yes it is possible, read this:

and the following slides

On Sun, Oct 9, 2016 at 2:04 AM, Ali Akhtar <<>>
Is it possible to have multiple clustering keys in cassandra, or some other way to order by
multiple columns?

For example, say I have a table of songs, and each song has a rating and a date.

I want to sort songs by rating first, and then with newer songs on top.

So if two songs have 5 rating, and one's date is 1st Feb, the other is 2nd Feb, then I want
the 2nd feb one to be sorted above the 1st feb one.

Like this:

Select * from songs order by rating, createdAt

Is this possible?

View raw message