Alex
Alex

Reputation: 61

How to translate complex sql into the equivalent Cassandra representation

Consider a table with the following table structure ...

CREATE TABLE table1 ( id integer, name varchar(32), ts timestamp );

SELECT * FROM table1 WHERE id = xx and ts between '2010/04/01' and '2010/04/11'

Given this query, how would you represent the given data-set using Cassandra?

Upvotes: 6

Views: 505

Answers (2)

Pranab
Pranab

Reputation: 663

You need to build a secondary index. One of the Cassandra index patterns described in my blog will solve your problem.

http://pkghosh.wordpress.com/2011/03/02/cassandra-secondary-index-patterns/

Pranab

Upvotes: 1

jbellis
jbellis

Reputation: 19377

build an index either on id or ts (whichever is more selective), query on that, and filter the other part manually.

(this is basically what a sql database does under the hood, btw.)

Upvotes: 3

Related Questions