如何在cassandra中同时使用in和order by
how to use in and order by at the same time in cassandra
我看官方文档:https://docs.datastax.com/en/cql/3.1/cql/cql_using/useColumnsSort.html
可以使用"SELECT * FROM users WHERE userID IN (102,104) ORDER BY age ASC;"
如何定义用户table或物化视图?
PAGING OFF 是必须的吗?
这是我当前的观点:
CREATE MATERIALIZED VIEW navigation_by_id_time AS
SELECT * FROM navigation
WHERE competition_id IS NOT NULL AND event_type_id IS NOT NULL AND event_id IS NOT NULL AND market_id IS NOT NULL AND market_start_time IS NOT NULL AND market_suspend_time IS NOT NULL
PRIMARY KEY (event_type_id, market_start_time, event_id, market_id, market_suspend_time);
此查询无效
select * from navigation_by_id_time where event_type_id in(1,2,3) order by market_start_time;
留言="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"
谢谢
Cassandra不支持使用bth IN和ORDER BY进行分页。 datastax 文档中也有说明 - Retrieval using IN keyword.
此外,如果您检查code,您还会得到更多解释。
在 JIRA-6722 中添加了检查,对行为的解释是:
It is however not all that easy in practice. If you query a full page
of each partition and there is many partitions in the IN, you'll load
tons of data in memory, defeating in large parts the goal of paging.
If you instead query less than the page size of each partition, you
now may need to re-query some of the partitions depending on what the
merge sort yield on those first pages.
作为结论:您需要关闭 paging in cqlsh. If you are using a Java client, this 可能会有帮助(也解释了更多内容)。
我看官方文档:https://docs.datastax.com/en/cql/3.1/cql/cql_using/useColumnsSort.html
可以使用"SELECT * FROM users WHERE userID IN (102,104) ORDER BY age ASC;"
如何定义用户table或物化视图?
PAGING OFF 是必须的吗?
这是我当前的观点:
CREATE MATERIALIZED VIEW navigation_by_id_time AS
SELECT * FROM navigation
WHERE competition_id IS NOT NULL AND event_type_id IS NOT NULL AND event_id IS NOT NULL AND market_id IS NOT NULL AND market_start_time IS NOT NULL AND market_suspend_time IS NOT NULL
PRIMARY KEY (event_type_id, market_start_time, event_id, market_id, market_suspend_time);
此查询无效
select * from navigation_by_id_time where event_type_id in(1,2,3) order by market_start_time;
留言="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"
谢谢
Cassandra不支持使用bth IN和ORDER BY进行分页。 datastax 文档中也有说明 - Retrieval using IN keyword.
此外,如果您检查code,您还会得到更多解释。
在 JIRA-6722 中添加了检查,对行为的解释是:
It is however not all that easy in practice. If you query a full page of each partition and there is many partitions in the IN, you'll load tons of data in memory, defeating in large parts the goal of paging. If you instead query less than the page size of each partition, you now may need to re-query some of the partitions depending on what the merge sort yield on those first pages.
作为结论:您需要关闭 paging in cqlsh. If you are using a Java client, this 可能会有帮助(也解释了更多内容)。