从2.1迁移到3.x时,Cassandra查询兼容性

时间:2017-05-12 14:48:01

标签: cassandra datastax datastax-enterprise cassandra-2.0 cassandra-3.0

我正在将我的数据从cassandra 2.1迁移到3.x。

我有以下cassandra查询,在我的`cassandra 2.1'中运行良好但在'cassandra 3.x'上出错了

查询"select * from event_users where app_id =1234 and event_name='login' and date in('2017-06-11', '2017-06-11')order by username desc limit 10";

Cassandra v2.1:工作正常

Cassandra v3.x:错误 InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot page queries with both ORDER BY and a IN restriction on the partition key; you must either remove the ORDER BY or the IN and sort client side, or disable paging for this query"

由于错误表示不同时使用IN和OrderBy并在客户端使用排序。

在客户端排序然后选择前10行是不可行的。

表架构CREATE TABLE event_users ( app_id bigint, event_name text, date text, username text, count counter, unique_count counter, PRIMARY KEY ((app_id, event_name, date), username) ) WITH CLUSTERING ORDER BY (username ASC)

解决此问题的更好方法是什么?

0 个答案:

没有答案