只有日期范围扫描Cassandra CQL时间戳 [英] only date range scanning Cassandra CQL timestamp

查看:545
本文介绍了只有日期范围扫描Cassandra CQL时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下所示的表格。

I have a table like given below.

CREATE TEST(
 HOURLYTIME TIMESTAMP,
 FULLTIME TIMESTAMP,
 DATA TEXT,
 PRIMARY KEY(HOURLYTIME,FULLTIME)
)


$ b b

我插入了记录(2014-12-12 00:00:00,2014-12-12 00:00:01,'Hello World')

I inserted the record (2014-12-12 00:00:00,2014-12-12 00:00:01,'Hello World')

我想基于日期时间范围搜索HOURLYTIME字段,其中包含小时记录。当我尝试像(

I would like to search based on date time range in HOURLYTIME field which holds hourly records.When i tried with token() like

select * from TEST where token(HOURLYTIME)= token('2014-12-12')

获取该日期的所有记录只有一小时记录,即

to get all the records for that date it returns only for one hour record i.e for

 2014-12-12 **00:00:00**

如果我添加日期范围

select * from TEST where token(HOURLYTIME)>=token('2014-12-12') AND token(HOURLYTIME)<=token('2014-12-14');

它提供错误:发现多个限制开始绑定

如何解决此问题。

我可以使用FULLTIME扫描,但我需要提供ALLOW FILTERING它将扫描整个记录和效率不高。

I am able to scan using FULLTIME but i need to provide ALLOW FILTERING which will scan whole records & inefficient.

推荐答案

不允许在不明确要求允许过滤的情况下将主键限制在某个范围。这可以防止需要进行全表扫描的查询,因为您注意到这些查询速度较慢,无法对真正的大数据大小进行扩展。其原因是主键值是随机散列的,因此指定主键值的范围基本上与提供两个松散耦合的随机数相同。例如在你的情况下,日期最有可能不是单调哈希。这意味着你想要的日期哈希值小于另一个值的哈希值将返回一个完全随机的数据集。

You are not allowed to restrict the primary key by a range without explicitly demanding it with allow filterting . This prevents queries which require a full table scan which as you note are slow and will not scale for true big data sizes. The reason for this is that the primary key values are randomly hashed so specifying a range of primary key values is basically the same as providing two loosely coupled random numbers. For example in your case dates most likely are not monotonically hashed. This means saying you want dates that hash to a value less that the hash of another value will return a completely random set of data.

这里的问题是,你的表设置不允许您实际要执行的查询。您需要对表进行建模,以便可以从单个分区获取所需的信息。

The issue here is that your table setup does not allow the queries that you actually want to perform. You need to model your tables so that the information you want can be obtained from a single partition.

这篇关于只有日期范围扫描Cassandra CQL时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆