Am I using cassandra efficiently?

China☆狼群 提交于 2019-12-13 05:51:31

问题


I have these table

CREATE TABLE user_info (
    userId uuid PRIMARY KEY,
    userName varchar,
    fullName varchar,
    sex varchar,
    bizzCateg varchar,
    userType varchar,
    about text,
    joined bigint,
    contact text,
    job set<text>,
    blocked boolean,
    emails set<text>,
    websites set<text>,
    professionTag set<text>,
    location frozen<location>
);

create table publishMsg
(
    rowKey uuid,
    msgId timeuuid,
    postedById uuid,
    title text,
    time bigint,
    details text,
    tags set<text>,
    location frozen<location>,
    blocked boolean,
    anonymous boolean,
    hasPhotos boolean,
    esIndx boolean, 
    PRIMARY KEY(rowKey, msgId)      
) with clustering order by (msgId desc);

create table publishMsg_by_user
(
    rowKey uuid,
    msgId timeuuid,
    title text,
    time bigint,
    details text,
    tags set<text>,
    location frozen<location>,
    blocked boolean,
    anonymous boolean,
    hasPhotos boolean,
    PRIMARY KEY(rowKey, msgId)      
) with clustering order by (msgId desc);

CREATE TABLE followers
(
    rowKey UUID,
    followedBy uuid,
    time bigint,
    PRIMARY KEY(rowKey, orderKey)
);
  1. I doing 3 INSERT statement in BATCH to put data in publishMsg publishMsg_by_user followers table.

  2. To show a single message I have to query three SELECT query on different table:

publishMsg - to get a publish message details where rowkey & msgId given.

userInfo - to get fullName based on postedById

followers - to know whether a postedById is following a given topic or not

Is this a fit way of using cassandra ? will that be efficient because the given scanerio data can't fit in single table.


回答1:


Sorry to ask this in an answer but I don't have the rep to comment.

Ignoring the tables for now, what information does your application need to ask for? Ideally in Cassandra, you will only have to execute one query on one table to get the data you need to return to the client. You shouldn't need to have to execute 3 queries to get what you want.

Also, your followers table appears to be missing the orderkey field.



来源:https://stackoverflow.com/questions/31729024/am-i-using-cassandra-efficiently

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!