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 C85EA17ECC for ; Sat, 10 Jan 2015 04:13:58 +0000 (UTC) Received: (qmail 17354 invoked by uid 500); 10 Jan 2015 04:13:57 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 17324 invoked by uid 500); 10 Jan 2015 04:13:56 -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 17313 invoked by uid 99); 10 Jan 2015 04:13:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jan 2015 04:13:56 +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 (athena.apache.org: domain of ajay.garga@gmail.com designates 209.85.215.46 as permitted sender) Received: from [209.85.215.46] (HELO mail-la0-f46.google.com) (209.85.215.46) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jan 2015 04:13:52 +0000 Received: by mail-la0-f46.google.com with SMTP id q1so17556654lam.5 for ; Fri, 09 Jan 2015 20:12:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=6UFYwt78/Q3/suepSLcrY9eGz9/YHj5TDhbQfvFOBIY=; b=IsmjWLDBfaJWNeIZav+BecwmbyGbA83Zm3+qTqA+BwAJPXqW95T1rjAnnWmKY2XlCs Izz5Xgs8fbsPpsZk9Q+yr9ST2tpvk0UnhfU6EKsiJVbimwRDy0gTkt3mb68yyjv5Yq+C ld4aKKE0G+vBDL88z2agDcJDn7KHvyEJNt+kiNdxG3KZYiBDYJHKXwhx/j6lCALsggrv fLD0UrNrgW86GMfBfNhTMvMtypTaJyL8TR82+1Xgb4BQ6SxgRS4nOS3fAFnji/wsAsUY AbVr6ngqXXZv9Rr6v9O7jX1g8kmV1bDjz/ua9JMKMYyAwDDiAiRuhKpVln7ryy+iinbG bSyA== MIME-Version: 1.0 X-Received: by 10.112.198.233 with SMTP id jf9mr25535311lbc.9.1420863121247; Fri, 09 Jan 2015 20:12:01 -0800 (PST) Received: by 10.25.22.90 with HTTP; Fri, 9 Jan 2015 20:12:01 -0800 (PST) Date: Sat, 10 Jan 2015 09:42:01 +0530 Message-ID: Subject: Re: Cassandra primary key design to cater range query From: Ajay To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=001a11c32cf49deddf050c447997 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c32cf49deddf050c447997 Content-Type: text/plain; charset=UTF-8 Hi, I read somewhere that the order of columns in the cluster key matters. Please correct me if I am wrong. For example, PRIMARY KEY((prodgroup), status, productid). Then the below query cannot run, select * from product where prodgroup='xyz' and prodid > 0 But this query can be run: select * from product where prodgroup='xyz' and prodid > 0 and status = 0 It means all the preceding part of the clustering key has to be provided in the query. So with that, if you want to query "Get details of a specific product"(either active or inactive), you might need to reorder the columns like PRIMARY KEY((prodgroup), productid, status). Thanks Ajay On Sat, Jan 10, 2015 at 6:03 AM, Tyler Hobbs wrote: > Your proposed model for the table to handle the last query looks good, so > I would stick with that. > > On Mon, Jan 5, 2015 at 5:45 AM, Nagesh wrote: > >> Hi All, >> >> I have designed a column family >> >> prodgroup text, prodid int, status int, , PRIMARY KEY ((prodgroup), >> prodid, status) >> >> The data model is to cater >> >> - Get list of products from the product group >> - get list of products for a given range of ids >> - Get details of a specific product >> - Update status of the product acive/inactive >> - Get list of products that are active or inactive (select * from >> product where prodgroup='xyz' and prodid > 0 and status = 0) >> >> The design works fine, except for the last query . Cassandra not allowing >> to query on status unless I fix the product id. I think defining a super >> column family which has the key "PRIMARY KEY((prodgroup), staus, >> productid)" should work. Would like to get expert advice on other >> alternatives. >> -- >> Thanks, >> Nageswara Rao.V >> >> *"The LORD reigns"* >> > > > > -- > Tyler Hobbs > DataStax > --001a11c32cf49deddf050c447997 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I read some= where that the order of columns in the cluster key matters. Please correct = me if I am wrong.

For example,

PRIMARY=20 KEY((prodgroup), status, productid).

Then the below query cann= ot run,

select * from product where prodgroup=3D'xyz' and pr= odid > 0

But this query can be run:
select * from produ= ct where prodgroup=3D'xyz' and prodid > 0 and status =3D 0
It means all the preceding part of the clustering key has to be pro= vided in the query. So with that, if you want to query "Get details of= a specific product"(either active or inactive), you might need to reo= rder the columns like PRIMARY=20 KEY((prodgroup), productid, status).

Thanks
Ajay
<= br>

On Sat, Jan 10= , 2015 at 6:03 AM, Tyler Hobbs <tyler@datastax.com> wrote:<= br>
Your proposed model for = the table to handle the last query looks good, so I would stick with that.<= br>

On Mon, Jan 5, 2015 at 5:45 AM, Nagesh &= lt;nageswara.= raov@gmail.com> wrote:
Hi All,

I have designed a column family

prodgroup text, prodid int, status int, , PRIMARY KEY ((prodgroup), prodid, status)

The data model is to cater

  • Get list of products from the product group
  • get list of pro= ducts for a given range of ids
  • Get details of a specific product
  • Update status of the product acive/inactive
  • Get list of prod= ucts that are active or inactive (select * from product where prodgroup=3D&= #39;xyz' and prodid > 0 and status =3D 0)

The design works fine, except for the last query . Cassandra not=20 allowing to query on status unless I fix the product id. I think=20 defining a super column family which has the key "PRIMARY=20 KEY((prodgroup), staus, productid)" should work. Would like to get=20 expert advice on other alternatives.

--
Thanks,
Nageswara Rao.V

&qu= ot;The LORD reigns"



--
Tyler Hobb= s
DataStax
<= /div>

--001a11c32cf49deddf050c447997--