cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peddi, Praveen" <pe...@amazon.com>
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.

Praveen

On Oct 10, 2016, at 6:22 PM, Ali Akhtar <ali.rac200@gmail.com<mailto:ali.rac200@gmail.com>>
wrote:

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?

:S

On Tue, Oct 11, 2016 at 3:19 AM, Ali Akhtar <ali.rac200@gmail.com<mailto:ali.rac200@gmail.com>>
wrote:
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 <nicolas.douillet@gmail.com<mailto:nicolas.douillet@gmail.com>>
wrote:
If I correctly understand the answers, the solution to your ordering question is to use clustering
keys.
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 <mikhail.krupitskiy@jetbrains.com<mailto:mikhail.krupitskiy@jetbrains.com>>
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
here:
http://stackoverflow.com/questions/35708118/where-and-order-by-clauses-in-cassandra-cql

Thanks,
Mikhail
On 10 Oct 2016, at 21:55, DuyHai Doan <doanduyhai@gmail.com<mailto:doanduyhai@gmail.com>>
wrote:

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

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

On Sun, Oct 9, 2016 at 11:48 AM, DuyHai Doan <doanduyhai@gmail.com<mailto:doanduyhai@gmail.com>>
wrote:
Yes it is possible, read this: http://www.slideshare.net/doanduyhai/datastax-day-2016-cassandra-data-modeling-basics/24

and the following slides

On Sun, Oct 9, 2016 at 2:04 AM, Ali Akhtar <ali.rac200@gmail.com<mailto:ali.rac200@gmail.com>>
wrote:
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?







Mime
View raw message