如何在Cassandra的查询中同时使用ORDER BY和IN? [英] How to use both ORDER BY and IN together in a query in Cassandra?

查看:193
本文介绍了如何在Cassandra的查询中同时使用ORDER BY和IN?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Cassandra 3.0.5。

I use Cassandra 3.0.5.

我在使用 ORDER BY 和<$ c时遇到问题$ c> IN 。

模式:

CREATE TABLE my_status.user_status_updates (
    username text,
    id timeuuid,
    body text,
    PRIMARY KEY (username, id)) 
    WITH CLUSTERING ORDER BY (id ASC)
    AND bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

查询:

SELECT username, id, UNIXTIMESTAMPOF(id), body
FROM user_status_updates
WHERE username IN ('carol', 'dave')
ORDER BY id DESC
LIMIT 2;




InvalidRequest:code = 2200 [Invalid query] message =无法显示页面在分区键上同时具有ORDER BY和IN限制的查询;您必须删除ORDER BY或IN并对客户端进行排序,或者禁用此查询的分页

InvalidRequest: 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"

我确定我已经看到人们对此进行了正确查询,所以我知道有一种解决方法。我需要做些什么才能使此查询正常工作,或者同时查询 ORDER BY IN 效率低下?

I'm sure I've seen people query this without errors, so I know there is a way to get around this. What do I need to do to make this query work, or is it inefficient to query both ORDER BY and IN together?

推荐答案

同时使用IN和ORDER BY将需要使用 PAGING OFF 命令。
cqlsh>放弃就是答案。

Using both IN and ORDER BY will require turning off paging with the PAGING OFF command in cqlsh. cqlsh> PAGING OFF is the answer.

这篇关于如何在Cassandra的查询中同时使用ORDER BY和IN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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