2017-01-30 73 views
1

当我们增加一个查询中每行更新的列数时,cassandra性能会增加还是下降。Cassandra性能:更新每行的列数

说,我们有一个表组(例如FB组),这approches是最好的:

1 /表集团(的groupId诠释,名称的字符串,成员地图(用户ID - >角色))

2 /表集团(的groupId诠释,名称的字符串,管理员设置[INT],主持人设置[INT],simpleMembers设置[INT])

我们假设一个用户都可以有主持人和阿明角色 所以当删除这个用户我们哈哈在第二种方法中更新了2列管理员和版主,而第一种情况下我们不得不只更新列成员。

回答

1

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; 

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

+0

假设你在一个组中有1000个成员。当组名更改时,您必须更新1000行。这不坏吗? –

+0

我们可以保持组名静态 – Gunwant

+1

基本上写性能不会受到影响,但如果行数非常长,并且始终从后面读取数据,读取性能将会受损。 随着时间的推移,当您插入数据时,cassandra也必须读取更多sstables以满足您的读取请求,因此如果您不小心,读取性能会随着时间的推移而降低。 –