Am I using cassandra effectively?
I have a 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)
);
-
I am doing 3 INSERT statements in BATCH to place data in a table
publishMsg
publishMsg_by_user
followers
. -
To show one message, I have to query three SELECT queries on another table:
publishMsg
- to receive a message about the publication, where rowkey
and msgId
.
userInfo
- get fullName
based onpostedById
followers
- know if it fits the postedById
given topic or not
Is this a good way to use cassandra? will be efficient because the scanned data cannot fit into one table.
source to share
Sorry to ask for this in return, but I have no comments to comment on.
Ignoring tables for now, what information does your application need? Ideally, in Cassandra, you would only need to execute one query on one table to get the data you need to return to the client. You won't need to do 3 queries to get what you want.
Also, there is no orderkey field in your subscribers table.
source to share