与复制因子相关的二级索引
Secondary index relating to Replication Factor
我正在为 Cassandra 中的一列使用二级索引 table.,
假设我有一个 5 节点集群 (192.168.1.1, 192.168.1.2, 192.168.1.3, 192.168.1.4, 192.168.1.5) 与键空间 复制因子为 '3' 并考虑以下 table,
CREATE TABLE nodestat (
uniqueId text,
totalCapacity int,
physicalUsage int,
flashMode text,
timestamp timestamp,
primary key (uniqueId, timestamp))
with clustering order by (timestamp desc);
在此,我将 uniqueId 的值设置为'test',这意味着我只有 只有一个名为 'test'[= 的分区35=]。
当我执行 getEndPoints 时,我可以看到数据仅驻留在 3 个节点中。
./nodetool getendpoints keyspacename nodestat test
192.168.1.1
192.168.1.2
192.168.1.3
所以我的分区数据在 3 个节点中可用,我在其中一列上做了二级索引,
CREATE CUSTOM INDEX nodeIp_idx ON nodestat(flashMode)
所以现在当我执行
select * from nodestat where uniqueId = 'test' AND flashMode = 'yes'
会去多少个节点采集数据?
select * from nodestat where uniqueId = 'test' AND flashMode = 'yes'
根据此查询,您正在使用分区键和二级索引。因此,它的行为将类似于基于所选一致性级别的普通查询。也就是说,如果 "local_one" 只有一个节点足以响应,如果 "local_quorum" 该 dc 中的法定数量的节点将必须响应。二级索引将进一步帮助缩小结果集。
请记住,二级索引对于该集群的每个节点中的数据都是本地的,因此存在于集群的所有节点中。附加参考 .
简而言之,Replication factor与Secondary index没有直接关系
我正在为 Cassandra 中的一列使用二级索引 table.,
假设我有一个 5 节点集群 (192.168.1.1, 192.168.1.2, 192.168.1.3, 192.168.1.4, 192.168.1.5) 与键空间 复制因子为 '3' 并考虑以下 table,
CREATE TABLE nodestat (
uniqueId text,
totalCapacity int,
physicalUsage int,
flashMode text,
timestamp timestamp,
primary key (uniqueId, timestamp))
with clustering order by (timestamp desc);
在此,我将 uniqueId 的值设置为'test',这意味着我只有 只有一个名为 'test'[= 的分区35=]。
当我执行 getEndPoints 时,我可以看到数据仅驻留在 3 个节点中。
./nodetool getendpoints keyspacename nodestat test
192.168.1.1 192.168.1.2 192.168.1.3
所以我的分区数据在 3 个节点中可用,我在其中一列上做了二级索引,
CREATE CUSTOM INDEX nodeIp_idx ON nodestat(flashMode)
所以现在当我执行
select * from nodestat where uniqueId = 'test' AND flashMode = 'yes'
会去多少个节点采集数据?
select * from nodestat where uniqueId = 'test' AND flashMode = 'yes'
根据此查询,您正在使用分区键和二级索引。因此,它的行为将类似于基于所选一致性级别的普通查询。也就是说,如果 "local_one" 只有一个节点足以响应,如果 "local_quorum" 该 dc 中的法定数量的节点将必须响应。二级索引将进一步帮助缩小结果集。
请记住,二级索引对于该集群的每个节点中的数据都是本地的,因此存在于集群的所有节点中。附加参考
简而言之,Replication factor与Secondary index没有直接关系