【发布时间】:2018-07-21 14:33:23
【问题描述】:
我有一个设置为:5 Cassandra 节点集群,RF =3,我为表“用户”中的列执行了二级索引,
1) 根据我使用链接对二级索引的研究:https://www.datastax.com/dev/blog/cassandra-native-secondary-index-deep-dive 我知道二级索引将存储在本地节点中。这是否意味着在五节点集群中只有一个节点可以使用二级索引?如果 user 表的 RF =3 中没有,二级索引表在多少个节点中可用?
2) 以下两个查询在执行上有何不同?
CREATE TABLE user(
user_group int PRIMARY KEY,
user_name text,
user_phone varint
);
CREATE INDEX username_idx ON user (user_name);
在这个表格设置中,
查询 1:SELECT * FROM user WHERE user_name = 'test';
查询 2:SELECT * FROM user WHERE user_group = 1 AND user_name = 'test';
以上两个查询会经过多少个节点(在5节点集群中)执行,两个查询的性能有何不同?
已编辑:
假设我有一张像下面这样的表格,
CREATE TABLE nodestat (
uniqueId text,
totalCapacity int,
physicalUsage int,
flashMode text,
timestamp timestamp,
primary key (uniqueId, timestamp))
with clustering order by (timestamp desc);
CREATE CUSTOM INDEX nodeIp_idx ON nodestat(flashMode)
查询 3:select * from nodestat where uniqueId = 'test' AND flashMode = 'yes'
所以在这种情况下,我的表中始终只有一个分区,那么二级索引搜索与没有分区键的二级索引相比有何不同?它的效率如何?
【问题讨论】:
-
引用docs.datastax.com/en/cql/3.3/cql/cql_using/…看什么时候有索引,什么时候没有索引
标签: indexing cassandra cassandra-3.0