开发者

How to translate complex sql into the equivalent Cassandra representation

开发者 https://www.devze.com 2022-12-28 16:20 出处:网络
Consider a table with the following table structure ... CREATE TABLE table1 ( id integer, name varchar(32),

Consider a table with the following table structure ...

CREATE TABLE table1 ( id integer, name varchar(32), 开发者_StackOverflow中文版 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?


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.)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消