Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BF546200BAD for ; Tue, 11 Oct 2016 00:48:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BDD70160AEB; Mon, 10 Oct 2016 22:48:36 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C8E28160AE1 for ; Tue, 11 Oct 2016 00:48:34 +0200 (CEST) Received: (qmail 43246 invoked by uid 500); 10 Oct 2016 22:48:33 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 43236 invoked by uid 99); 10 Oct 2016 22:48:33 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Oct 2016 22:48:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id D696EC31EF for ; Mon, 10 Oct 2016 22:48:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.129 X-Spam-Level: ** X-Spam-Status: No, score=2.129 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id ya9utp8pMJP4 for ; Mon, 10 Oct 2016 22:48:30 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 47E875FAC8 for ; Mon, 10 Oct 2016 22:48:30 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id x79so6885081lff.0 for ; Mon, 10 Oct 2016 15:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=J484kt6VA+teZeGGr4nPknBkrt8CYbGPvi4MoLhKfNk=; b=cTx/LwWYaLIjpVzCY2vCO8g1K0UVeeBkgudaQHrsyATQFfSbd3UoLgWFSBj89Cel70 DRaIWNnmv1jq9cd7L0XK74CqeocXoey2f5/g5oHL2v8CeTHCyTFARV1IoShYINV/B0PD vh27vh2tXNGALzMxl0qoJ/22TbDyYSTUiMOFS7nmnIDctu2L7URLVKa6qFVFts/pVtPt xjAKrQQ3KusoRTkJmrjRIlO9kMOYWaTXYNBpV0WuQOb6Rc0SwNnmhV5kUOR125IFbm5q 9RlVyoFB3ilUtn4BnLsuBhdgAsmiSVemvJUrHlSm13YWd3J7hTEZ4ObGJRYdwA8LpO1u 8Paw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=J484kt6VA+teZeGGr4nPknBkrt8CYbGPvi4MoLhKfNk=; b=JN5SEYx5ZP2sqACnLoErUY24U4mE66BXL5nqQibC77byjU6W8fUncsVVBaxedS5TM3 B7XXCqje94/WPdoEYI5jgDq9xX78OFOop59gU7DrPbXpiwYBuDpg9KNrR5YNsExbngjW 3QHC7wwCBk0pI7W+w9RxPqD3VWbir6wIUAQ36XSH0dZ8iS0c4TCHp+yBddYL5N5NUU/7 ZcXnGh0ubl1astYnmpvvpFY1Z/zdB6HwQICiGhOwuc2nqT7obtvOuAR59/b5Y6EiuL/l 7eM8J1WI5+h66IpbXwusewluPd1PvxasGkOeNkLGiBDMKvSNFrFPpd8Mzx0/qp/kpXYO eRgw== X-Gm-Message-State: AA6/9RnT3Tsaf/tJGcYC6fW0uv+Uzoo1D5UCwnyE+MpaO4pXQYBOxGrfZrPvGnnmb+N79aAcVl7upWGO7M7VJA== X-Received: by 10.194.201.36 with SMTP id jx4mr644718wjc.38.1476139705648; Mon, 10 Oct 2016 15:48:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.41.194 with HTTP; Mon, 10 Oct 2016 15:48:24 -0700 (PDT) In-Reply-To: <5107E625-23E0-431C-909C-6B9112EBE249@amazon.com> References: <86F98979-3E22-4AAD-8BEA-4F84EF1027CF@jetbrains.com> <5107E625-23E0-431C-909C-6B9112EBE249@amazon.com> From: Ali Akhtar Date: Tue, 11 Oct 2016 03:48:24 +0500 Message-ID: Subject: Re: Ordering by multiple columns? To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=047d7b873caccb4ce3053e8a8e41 archived-at: Mon, 10 Oct 2016 22:48:36 -0000 --047d7b873caccb4ce3053e8a8e41 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Okay.. so, how would you achieve the above scenario in cassandra? On Tue, Oct 11, 2016 at 3:25 AM, Peddi, Praveen wrote: > 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 documentati= on > and understand the basics before start using it. Otherwise you could easi= ly > abuse it inadvertently. > > Praveen > > On Oct 10, 2016, at 6:22 PM, Ali Akhtar wrote: > > E.g if I wanted to select * from foo where last_updated <=3D ? > > 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 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> 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 =C3=A0 22:15, Mikhail Krupitskiy < >>> mikhail.krupitskiy@jetbrains.com> a =C3=A9crit : >>> >>>> Looks like ordering by multiple columns in Cassandra has few sides tha= t >>>> are not obvious. >>>> I wasn=E2=80=99t able to find this information in the official documen= tation >>>> but it=E2=80=99s 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 wrote: >>>> >>>> No, we didn't record the talk this time unfortunately :( >>>> >>>> On Mon, Oct 10, 2016 at 8:17 PM, Ali Akhtar >>>> wrote: >>>> >>>> Really helpful slides. Is there a video to go with them? >>>> >>>> On Sun, Oct 9, 2016 at 11:48 AM, DuyHai Doan >>>> wrote: >>>> >>>> Yes it is possible, read this: http://www.slideshare.ne >>>> t/doanduyhai/datastax-day-2016-cassandra-data-modeling-basics/24 >>>> >>>> and the following slides >>>> >>>> On Sun, Oct 9, 2016 at 2:04 AM, Ali Akhtar >>>> 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 on= e. >>>> >>>> Like this: >>>> >>>> Select * from songs order by rating, createdAt >>>> >>>> Is this possible? >>>> >>>> >>>> >>>> >>>> >>>> >> > --047d7b873caccb4ce3053e8a8e41 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Okay.. so, how would you achieve the above scenario in cas= sandra?

On T= ue, Oct 11, 2016 at 3:25 AM, Peddi, Praveen <peddi@amazon.com> wrote:
That's not just a bad idea but that= 9;s impossible. Any field that is part of primary key is immutable. You sho= uld read up the Cassandra documentation and understand the basics before st= art using it. Otherwise you could easily abuse it inadvertently.

Praveen

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

E.g if I wanted to select * from foo where last_updated &l= t;=3D ?=C2=A0

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

:S

On Tue, Oct 11, 2016 at 3:19 AM, Ali Akhtar <ali.rac200@gm= ail.com> wrote:
Huh - So if I wanted to search / filter by a timestamp fie= ld, and this timestamp needed to get updated, that won't be possible?

On Tue, Oct 11, 2016 at 3:07 AM, Nicolas Douille= t <nicolas= .douillet@gmail.com> wrote:
If I correctly understand the answers, the solution to your ordering q= uestion is to use clustering keys.
I'm agree, but I just wanted to warn you about one limitation : = =C2=A0the 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 k= ey can be tricky if the value has to be frequently updated) =C2=A0


Le=C2=A0lun. 10 oct. 2016 =C3=A0=C2=A022:15, Mikhail Krupi= tskiy <mikhail.krupitskiy@jetbrains.com> a =C3=A9crit=C2=A0:
Looks like ordering by multiple columns in Cassandra has few sides that are= not obvious.
I wasn=E2=80=99t able to find this information in the offic= ial documentation but it=E2=80=99s quite well described here:
On 10 Oct 2016, at 21:55, DuyHai Doan <doanduyhai@gmail.com> wrote:

No, we didn't record the talk this time unf= ortunately :(

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

On Sun, Oct 9, 2016 at 11:48 AM, DuyHai Doan <doanduyhai@gmail.com> wrote:

On Sun, Oct 9, 2016 at 2:04 AM, Ali Akhtar <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 s= ongs on top.

So if two songs have 5 rating, and one's date is 1st Fe= b, 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?







--047d7b873caccb4ce3053e8a8e41--