gpt4 book ai didi

cassandra - Cassandra 中的结果顺序

转载 作者:行者123 更新时间:2023-12-04 21:05:36 30 4
gpt4 key购买 nike

我有两个关于 Cassandra 查询结果的问题。

  • 当我在 Cassandra 中对表进行“完全”选择(即 select * from table )时,是否保证结果将按分区标记的递增顺序返回?
    例如,有下表:
    create table users(id int, name text, primary key(id));

    是否保证以下查询将返回 token 列中值增加的结果?
    select token(id), id from users;

    如果是这样,是否也保证数据分布到集群中的多个节点上?
  • 如果上述问题的答案是"is",那么我们使用二级索引是否仍然有效?例如,如果我们有以下索引:
    create index on users(name);

    我们使用索引查询表:
    select token(id), id from users where name = 'xyz';

    对结果的顺序有任何保证吗?

  • 上述问题的动机是 token 是否适合用于实现分页和/或恢复损坏的较长“数据导出”。

    编辑:网上有多个资源表明订单与 token 订单匹配(例如,在 partitioner resultsthis Datastax page 的描述中):

    Without a partition key specified in the WHERE clause, the actual order of the result set then becomes dependent on the hashed values of userid.



    但是,Cassandra 官方文档中没有指定结果的顺序,例如。的 SELECT statement .

    最佳答案

    Is it guaranteed that the following query will return the results with increasing values in the token column?



    是的

    If so, is it also guaranteed if the data is distributed to multiple nodes in the cluster?



    数据分布与检索到的数据的排序是正交的,没有关系

    If the anwer to the above question is 'yes', is it still valid if we use secondary index?



    是的,即使您使用二级索引(无论是 SASI 还是 native 实现)查询数据,返回的结果也将始终按 token 顺序排序。为什么 ?技术解释在我的博客文章中给出: http://www.doanduyhai.com/blog/?p=13191#cluster_read_path

    如果您希望搜索返回按某些列值排序的数据,那么这就是解释为什么 SASI 不合适的主要原因。只有真正的搜索引擎集成(如 Datastax Enterprise Search)才能为您提供正确的排序,因为它绕过了集群读取路径层。

    关于cassandra - Cassandra 中的结果顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47011504/

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