gpt4 book ai didi

select - CQL3 SELECT...IN 子句中的元组数量是否有任何限制?

转载 作者:行者123 更新时间:2023-12-01 11:38:42 25 4
gpt4 key购买 nike

Cassandra CQL3 SELECT 语句允许使用 IN 元组,如 in

SELECT * FROM posts
WHERE userid='john doe' AND (blog_title, posted_at)
IN (('John''s Blog', '2012-01-01), ('Extreme Chess', '2014-06-01'))

从 CQ3 规范中可以看出:http://cassandra.apache.org/doc/cql3/CQL.html#selectStmt

SELECT 的 IN 子句中可以使用的元组数量有限制吗?最大值是多少?

最佳答案

DataStax 的 Rebecca Mills 对 IN 语句(Things you should be doing when using Cassandra drivers - 第 22 点)中允许的键数提供了明确的限制:

...specifically the limit on the number of keys in an IN statement, the most you can have is 65535. But practically speaking you should only be using small numbers of keys in INs, just for performance reasons.

我假设该限制也适用于您可以指定的元组数量。不过老实说,我不会试图超越这一点。如果你发送的数量很大,它根本不会表现良好。 CQL documentation on the SELECT CLAUSE警告用户:

When not to use IN

The recommendations about when not to use an index apply to using IN in the WHERE clause. Under most conditions, using IN in the WHERE clause is not recommended. Using IN can degrade performance because usually many nodes must be queried. For example, in a single, local data center cluster with 30 nodes, a replication factor of 3, and a consistency level of LOCAL_QUORUM, a single key query goes out to two nodes, but if the query uses the IN condition, the number of nodes being queried are most likely even higher, up to 20 nodes depending on where the keys fall in the token range.

可以说,虽然您可以通过的元组的最大数量是一个数学问题,但您应该通过的元组数量将取决于您的集群配置, JVM实现,还有一点常识。

关于select - CQL3 SELECT...IN 子句中的元组数量是否有任何限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24350842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com