Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 270B511F6A for ; Thu, 18 Sep 2014 16:36:26 +0000 (UTC) Received: (qmail 10366 invoked by uid 500); 18 Sep 2014 16:36:23 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 10328 invoked by uid 500); 18 Sep 2014 16:36:23 -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 10318 invoked by uid 99); 18 Sep 2014 16:36:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Sep 2014 16:36:23 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of doanduyhai@gmail.com designates 209.85.223.182 as permitted sender) Received: from [209.85.223.182] (HELO mail-ie0-f182.google.com) (209.85.223.182) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Sep 2014 16:35:57 +0000 Received: by mail-ie0-f182.google.com with SMTP id y20so1589004ier.27 for ; Thu, 18 Sep 2014 09:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=A/j8LfOm+6vDfaJT7eFzZj/anbPocRVAmobLF52VQA4=; b=DvVNBL6qswZMDhY/QYCblA8z2VfY+OdZvBB5tj2d7sdYaFC9Oq4lH1o1+AoxzXiGWE 1JOHcar65U3lDjG2tBDrbMi7K4N8RTOx/djnuczntVvN+bWu+DFwzDDGF7REhWSh5J1b OLMC4Rp0n0t37pk5JfqxL+tiJVCAcVUBp/QpEUBMjW7cGXSXbO0J/6mCSP5h3ZquPkRE YJ4x8J7BEGZBzovoDwWEScc/e116KkyTBh+xvv10vP4/KydLHV59IE8rKg0x/AuigjRI zOa1njM565mcMY4khk+Gjslv8LFUasRaG7AAiniX9KhZ1lGD7HXePlBLQ8osrB1a+zgq iPTg== MIME-Version: 1.0 X-Received: by 10.43.111.6 with SMTP id em6mr13949421icc.21.1411058155072; Thu, 18 Sep 2014 09:35:55 -0700 (PDT) Received: by 10.76.169.72 with HTTP; Thu, 18 Sep 2014 09:35:55 -0700 (PDT) In-Reply-To: References: Date: Thu, 18 Sep 2014 18:35:55 +0200 Message-ID: Subject: Re: index partition key From: DuyHai Doan To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=bcaec51718651736aa05035994b6 X-Virus-Checked: Checked by ClamAV on apache.org --bcaec51718651736aa05035994b6 Content-Type: text/plain; charset=UTF-8 Your query "select * from testcf where key1 > 'Lucas';" does work if you choose the old OrderPartioner but since it's considered absolute evil (for good reason, load distribution is horrendous), pratically it is not possible to do your query. And it's the same thing with secondary index. Query with inequality on secondary index translates into full cluster scan... Regards Duy Hai DOAN On Thu, Sep 18, 2014 at 5:44 PM, Marcelo Elias Del Valle < marcelo@s1mbi0se.com.br> wrote: > Hi, > > This question is just for curiosity purposes, I don't need this in my > solution, but it's something I was asking myself... > > Is there a way of indexing the partition key values in Cassandra? Does > anyone needed this and found a solution of any kind? > > For example, I know the sample bellow doesn't work, but would it be > possible somehow? > I know select * from testcf where token(key1) > token('Lucas'); works, but > the question is ordering by the values, even using another CF or index of > any kind... > > CREATE KEYSPACE IF NOT EXISTS testks > WITH REPLICATION = { 'class' : 'SimpleStrategy', > 'replication_factor': '1' }; > > > CREATE TABLE IF NOT EXISTS testcf ( > key1 varchar, > value varchar, > PRIMARY KEY ((key1))); > > CREATE INDEX testidx on testks.testcf (key1); > > insert into testcf (key1, value) values ('Lucas', 'value1'); > insert into testcf (key1, value) values ('Luiz', 'value2'); > insert into testcf (key1, value) values ('Edu', 'value3'); > insert into testcf (key1, value) values ('Marcelo', 'value4'); > > select * from testcf order by key1; > select * from testcf where key1 > 'Lucas'; > > > Best regards, > Marcelo. > --bcaec51718651736aa05035994b6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Your query "select * from testcf where key1= > 'Lucas';" does work if you choose the old OrderPartioner= but since it's considered absolute evil (for good reason, load distrib= ution is horrendous), pratically it is not possible to do your query.
And it's the same thing with secondary index. Query with inequa= lity on secondary index translates into full cluster scan...

R= egards

=C2=A0Duy Hai DOAN

On Thu, Sep 18, 2014 at 5:44 PM, Marcelo Elias Del= Valle <marcelo@s1mbi0se.com.br> wrote:
Hi,

This question i= s just for curiosity purposes, I don't need this in my solution, but it= 's something I was asking myself...

Is there a= way of indexing the partition key values in Cassandra? Does anyone needed = this and found a solution of any kind?

For example= , I know the sample bellow doesn't work, but would it be possible someh= ow?
I know=C2=A0select * from testcf where token(key1) > token= ('Lucas'); works, but the question is ordering by the values, even = using another CF or index of any kind...

CREA= TE KEYSPACE IF NOT EXISTS testks
=C2=A0 WITH REPLICATION =3D { &#= 39;class' : 'SimpleStrategy',
=C2=A0 'replication= _factor': '1' };


CREATE= TABLE IF NOT EXISTS testcf (
=C2=A0 key1 varchar,
=C2= =A0 value varchar,
=C2=A0 PRIMARY KEY ((key1)));

CREATE INDEX testidx on testks.testcf (key1);

=
insert into testcf (key1, value) values ('Lucas', 'value1&= #39;);
insert into testcf (key1, value) values ('Luiz', &= #39;value2');
insert into testcf (key1, value) values ('E= du', 'value3');
insert into testcf (key1, value) valu= es ('Marcelo', 'value4');

select *= from testcf order by key1;
select * from testcf where key1 > = 'Lucas';


Best regards= ,
Marcelo.

--bcaec51718651736aa05035994b6--