cassandra中的日期范围查询

date range query in cassandra

我是 Cassandra 的新手。

我们有table结构是这样的

CREATE TABLE keyspace.events ( id bigint, msg_time bigint, status int, uuid timeuuid, message text, PRIMARY KEY (id, msg_time, status, uuid) ) WITH CLUSTERING ORDER BY (msg_time ASC, status ASC, uuid ASC) CREATE INDEX timestamp ON hh_keyspace.game_events (msg_time);

我们插入 TTL 为 32 天的数据。分析团队只需要最后 1 天的数据。使用 msg_time > '' ALLOW FILTERING 的查询将对性能产生巨大影响。

分析团队 运行 每天查询。还有其他获取数据的方法吗?

Query with msg_time > '' ALLOW FILTERING will have huge performance impact.

ALLOW FILTERING 意味着正常生产数据集上的 SURELY TIMEOUT。不足为奇。

Are there any other ways to get the data

为您的 table 建模,以便查询(给我最后一天的数据)非常快。 对于尽可能大的负载,您希望每天 有多少事件

我意识到最好的方法是复制数据,因为在 Cassandra 中写入很便宜。我们写入另一个具有不同密钥结构的 table。

参考:

1) http://blog.websudos.com/2014/08/16/a-series-on-cassandra-part-1-getting-rid-of-the-sql-mentality/(第 4 节。在应用程序级别复制数据并保持一致性)

2) http://blog.websudos.com/2014/08/23/a-series-on-cassandra-part-2-indexes-and-keys/(部分 - 二级索引)