2017-01-30 63 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以滿足您的讀取請求,因此如果您不小心,讀取性能會隨着時間的推移而降低。 –