cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Wille <rwi...@fold3.com>
Subject Re: using or in select query in cassandra
Date Mon, 02 Mar 2015 18:04:11 GMT
I would also like to add that if you avoid IN and use async queries instead, it is pretty trivial
to use a semaphore or some other limiting mechanism to put a ceiling on the amount on concurrent
work you are sending to the cluster. If you use a query with an IN clause with a thousand
things, you’ll make the cluster look for a thousand records concurrently. If you issue a
thousand asyncQueries, and use a limiting mechanism, then you can control how much load you
are placing on the server.

I built a nice wrapper around the Session object, and one of the things that is built into
the wrapper is the ability to limit the number of concurrent async queries. It’s a really
nice and simple feature to have.

Robert

On Mar 2, 2015, at 10:33 AM, Jonathan Haddad <jon@jonhaddad.com<mailto:jon@jonhaddad.com>>
wrote:

I'd like to add that in() is usually a bad idea.  It is convenient, but not really what you
want in production.  Go with Jens' original suggestion of multiple queries.

I recommend reading Ryan Svihla's post on why in() is generally a bad thing: http://lostechies.com/ryansvihla/2014/09/22/cassandra-query-patterns-not-using-the-in-query-for-multiple-partitions/

On Mon, Mar 2, 2015 at 12:36 AM Jens Rantil <jens.rantil@tink.se<mailto:jens.rantil@tink.se>>
wrote:
Hi Rahul,

No, you can't do this in a single query. You will need to execute two separate queries if
the requirements are on different columns. However, if you'd like to select multiple rows
of with restriction on the same column you can do that using the `IN` construct:

select * from table where id IN (123,124);

See [1] for reference.

[1] http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/select_r.html

Cheers,
Jens

On Mon, Mar 2, 2015 at 7:06 AM, Rahul Srivastava <srivastava.robin71@gmail.com<mailto:srivastava.robin71@gmail.com>>
wrote:
Hi
 I want to make uniqueness for my data so i need to add OR clause  in my WHERE clause.
ex: select * from table where id =123 OR name ='abc'
so in above i want that i get data if my id is 123 or my name is abc .

is there any possibility in cassandra to achieve this .




--
Jens Rantil
Backend engineer
Tink AB

Email: jens.rantil@tink.se<mailto:jens.rantil@tink.se>
Phone: +46 708 84 18 32
Web: www.tink.se<http://www.tink.se/>

Facebook<https://www.facebook.com/#!/tink.se> Linkedin<http://www.linkedin.com/company/2735919?trk=vsrp_companies_res_photo&trkInfo=VSRPsearchId%3A1057023381369207406670%2CVSRPtargetId%3A2735919%2CVSRPcmpt%3Aprimary>
Twitter<https://twitter.com/tink>


Mime
View raw message