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 8A36C83DF for ; Sun, 14 Aug 2011 14:10:25 +0000 (UTC) Received: (qmail 95587 invoked by uid 500); 14 Aug 2011 14:10:23 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 95407 invoked by uid 500); 14 Aug 2011 14:10:22 -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 95399 invoked by uid 99); 14 Aug 2011 14:10:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Aug 2011 14:10:22 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jason.rutherglen@gmail.com designates 209.85.220.172 as permitted sender) Received: from [209.85.220.172] (HELO mail-vx0-f172.google.com) (209.85.220.172) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Aug 2011 14:10:16 +0000 Received: by vxi29 with SMTP id 29so4230334vxi.31 for ; Sun, 14 Aug 2011 07:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=wBp7BsIOvYIo/SM1qwIAxWAAYk9EnOmMHaj4tEu5qto=; b=CYg4ZapqacKVjGRmSocdGkI1+RwHQPBfEAlyChyVu8KLeNCxdlkXbKGQlHQPY9QVO+ uuSs/AUgnfg3D53iEvKFAGJRkdMGbHfQMFTTqJxgmSYezClj5Z43v/JKO6/9neJefGzv 7fIvvwyomNLHNT/ZSteH8XHW/hl0ADhr+oGoE= MIME-Version: 1.0 Received: by 10.52.28.162 with SMTP id c2mr2784523vdh.515.1313330995713; Sun, 14 Aug 2011 07:09:55 -0700 (PDT) Received: by 10.52.182.234 with HTTP; Sun, 14 Aug 2011 07:09:55 -0700 (PDT) In-Reply-To: References: <20110803015822.204140@gmx.net> <1312339364.2893.10.camel@erebus.lan> <20110813214939.183200@gmx.net> <20110814125313.326920@gmx.net> Date: Sun, 14 Aug 2011 07:09:55 -0700 Message-ID: Subject: Re: CQL: No indexed column error when < or <= in WHERE clause From: Jason Rutherglen To: user@cassandra.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This will be fully solved with CASSANDRA-2915 which will use Lucene as a the secondary index type implementation. Lucene has extremely fast range queries built in. On Sun, Aug 14, 2011 at 6:38 AM, Sal Fuentes wrote: > The important piece that is mentioned in Jonathan's link is this: > "One consequence of the KEYS index type being more like a hash index than= a > btree is shown here: even though birth_date is indexed, Cassandra couldn= =E2=80=99t > perform the range query =E2=80=9C> 1970=E2=80=B3 against it." > hash index vs a btree index. Basically what this means is that these > secondary indexes do not currently support queries of the type greater th= an, > less than on a single column. > However, Cassandra will allow you to submit these types of queries when y= ou > have multiple indexed columns; even though it may not be very efficient. > "We can perform the range query now that the state column is also indexed= , > so Cassandra can use the state predicate as the primary and filter on the > other with a nested loop." > [default@demo] get users where birth_date =3D 1973; > ------------------- > RowKey: prothfuss > =3D> (column=3Dbirth_date, value=3D1973, timestamp=3D1313327531411000) > =3D> (column=3Dfull_name, value=3DPatrick Rothfuss, timestamp=3D131332752= 6515000) > 1 Row Returned. > [default@demo] get users where birth_date > 1972; > No indexed columns present in index clause with operator EQ > [default@demo] get users where birth_date < 1974; > No indexed columns present in index clause with operator EQ > [default@demo] get users where birth_date >=3D 1973; > No indexed columns present in index clause with operator EQ > > On Sun, Aug 14, 2011 at 6:11 AM, Martin von Zweigbergk > wrote: >> >> Hi Jens, >> >> I have never used CQL myself and I have barely used Cassandra, but I >> think I've seen it mentioned before on this list that you need to use >> compare for equality on at least one column (as indicated by "No >> indexed columns present in by-columns clause with "equals" operator"). >> The lookup will then be done based on that column and additional >> filtering (such as for "less than") will be done on the result of the >> first lookup, which can potentially be a large data set. You might >> also want to redesign your data model to allow for a more efficient >> lookup. >> >> Hope that helps (despite my lack of knowledge on the subject) >> Martin >> >> On Sun, Aug 14, 2011 at 8:53 AM, Jens Hartung wrote: >> > I had indexed the number column in station column family. Do I also ha= ve >> > to index another column? >> > >> > What I'm wondering, when I type "get station where number =3D 8210;" a= ll >> > works fine, but when I type "get station where number < 8210;" I'll ge= t >> > mentioned exception. >> > >> > Is there something, that I misunderstand? >> > >> > -------- Original-Nachricht -------- >> >> Datum: Sat, 13 Aug 2011 18:14:05 -0700 >> >> Von: Jonathan Ellis >> >> An: user@cassandra.apache.org >> >> Betreff: Re: CQL: No indexed column error when < or <=3D in WHERE cla= use >> > >> >> This is covered in >> >> >> >> http://www.datastax.com/dev/blog/whats-new-cassandra-07-secondary-ind= exes >> >> >> >> On Sat, Aug 13, 2011 at 2:49 PM, Jens Hartung wrote: >> >> > Hi together, >> >> > >> >> > first, I'm using Cassandra Version 0.8.4 and access it via CQL 1.0.= 3. >> >> > >> >> > When I select data from Cassandra with =3D in WHERE clause, everyth= ing >> >> works fine, but when using <=3D or < in WHERE clause, I always get >> >> following >> >> Exception: >> >> > >> >> > java.sql.SQLException: No indexed columns present in by-columns >> >> > clause >> >> with "equals" operator >> >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0at >> >> >> >> org.apache.cassandra.cql.jdbc.CassandraStatement.executeQuery(Cassand= raStatement.java:242) >> >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0at >> >> >> >> columnfamily.queries.CassandraQueries.singleColumnSelect(CassandraQue= ries.java:147) >> >> > ... >> >> > >> >> > My select-statement: "SELECT number FROM station WHERE number <=3D >> >> > 8210;" >> >> > >> >> > Output of describe keyspace (within cli): >> >> > ColumnFamily: station >> >> > =C2=A0 =C2=A0 =C2=A0Key Validation Class: org.apache.cassandra.db.m= arshal.UTF8Type >> >> > =C2=A0 =C2=A0 =C2=A0Default column value validator: >> >> org.apache.cassandra.db.marshal.UTF8Type >> >> > =C2=A0 =C2=A0 =C2=A0Columns sorted by: org.apache.cassandra.db.mars= hal.UTF8Type >> >> > =C2=A0 =C2=A0 =C2=A0Row cache size / save period in seconds: 0.0/0 >> >> > =C2=A0 =C2=A0 =C2=A0Key cache size / save period in seconds: 200000= .0/14400 >> >> > =C2=A0 =C2=A0 =C2=A0Memtable thresholds: 0.2109375/1440/45 (million= s of >> >> ops/minutes/MB) >> >> > =C2=A0 =C2=A0 =C2=A0GC grace seconds: 864000 >> >> > =C2=A0 =C2=A0 =C2=A0Compaction min/max thresholds: 4/32 >> >> > =C2=A0 =C2=A0 =C2=A0Read repair chance: 1.0 >> >> > =C2=A0 =C2=A0 =C2=A0Replicate on write: true >> >> > =C2=A0 =C2=A0 =C2=A0Built indexes: [station.station_number_idx] >> >> > =C2=A0 =C2=A0 =C2=A0Column Metadata: >> >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0[...] >> >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0Column Name: number >> >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Validation Class: org.apache.cass= andra.db.marshal.LongType >> >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Index Name: station_number_idx >> >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Index Type: KEYS >> >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0[...] >> >> > >> >> > Are the <, <=3D, >=3D, > operators not supported at this time? >> >> > >> >> > Greetings >> >> > Jens >> >> > -- >> >> > NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zur=C3=BCck-Garant= ie! >> >> > Jetzt informieren: http://www.gmx.net/de/go/freephone >> >> > >> >> >> >> >> >> >> >> -- >> >> Jonathan Ellis >> >> Project Chair, Apache Cassandra >> >> co-founder of DataStax, the source for professional Cassandra support >> >> http://www.datastax.com >> > >> > -- >> > NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zur=C3=BCck-Garantie! >> > Jetzt informieren: http://www.gmx.net/de/go/freephone >> > > > > > -- > Salvador Fuentes Jr. >