我使用cassandra高效吗? [英] Am I using cassandra efficiently?

查看:261
本文介绍了我使用cassandra高效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这些表

  CREATE TABLE user_info(
userId uuid PRIMARY KEY,
userName varchar ,
fullName varchar,
sex varchar,
bizzCateg varchar,
userType varchar,
关于文本,
加入bigint,
联系人文本,
job set< text>,
blocked boolean,
电子邮件集< text> ;,
网站集< text> ;,
professionTag集< text& b location frozen< location>
);

create table publishMsg

rowKey uuid,
msgId timeuuid,
postedById uuid,
title text,
time bigint ,
详细信息文本,
标签集< text>,
位置冻结< location> ;,
已阻止布尔值
匿名布尔值
hasPhotos布尔值
esIndx boolean,
PRIMARY KEY(rowKey,msgId)
)聚类顺序为(msgId desc);

创建表publishMsg_by_user

rowKey uuid,
msgId timeuuid,
标题文本,
时间bigint,
详细文本,
tags set< text>,
location frozen< location>,
blocked boolean,
anonymous boolean,
hasPhotos boolean,
PRIMARY KEY ,msgId)
)与聚类顺序(msgId desc);

CREATE TABLE followers

rowKey UUID,
followBy uuid,
time bigint,
PRIMARY KEY(rowKey,orderKey)
);




  1. 我在BATCH中执行3 INSERT语句, publishMsg publishMsg_by_user followers 要显示单个消息,我必须查询不同表上的三个SELECT查询:


publishMsg - 获取发布消息详细信息其中 rowkey msgId



userInfo c $ c> fullName 基于 postedById



- 了解 postedById 是否在指定主题之后



一个适合的方式使用cassandra?

解决方案

很抱歉,在一个答案中提出这个问题,我没有代表评论。



现在忽略这些表,您的应用程序需要什么信息?理想情况下,在Cassandra中,您只需对一个表执行一个查询即可获取需要返回客户端的数据。你不应该需要执行3个查询来获得你想要的。



此外,您的关注者表格似乎缺少orderkey栏位。


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.

解决方案

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.

这篇关于我使用cassandra高效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆