1

当我们在一个查询中增加每行要更新的列数时,cassandra 的性能会提高还是降低。

假设我们有一个最好的表组(例如 FB 组):

1/ 表组(groupId Int, name String, members Map(userId -> roles))

或者

2/ 表组(groupId Int, name String, admins Set[Int], moderators Set[Int], simpleMembers Set[Int])

我们假设用户可以拥有版主和管理员角色,因此在删除此用户时,我们必须在第二种方法中更新 2 列管理员和版主,而在第一种方法中,我们必须只更新列成员。

4

1 回答 1

1

来自Marko的评论的Copid——

Basically the write performance will not be affected but the read performance will suffer if you have very
very long rows and always read stuff from the back of it. 
Over time when you insert the data cassandra will also have to read more sstables to satisfy your read requests, 
so with time read performance will degrade if you are not careful

我只想考虑避免删除。如果我们可以设计上面的用例来避免删除。

       create table groups(
        groupid int,
        userid int,
        groupName text static, 
        attributes Map( text , text),
        primary key (groupid,userid)
    );

查询——

insert into groups (groupid,userid,groupName,attributes) values (100,200,'friends',{'admin':'false','moderator':'true','user-member':'true'});

update groups set attributes['admin'] = 'true' where groupid=100 and userid = 200;

这样我们就不必删除表中的任何值。同样在将来,如果我们想添加新属性,我们不必更改表定义。

于 2017-01-30T12:22:53.433 回答