0

I have created a table that contains the userid, the content that they posted on their newsfeed, the date of when they posted it, and a primary key(I am using nodejs)

my first shot at retrieving the data was me trying use an IN clause and passing an array as a paramater.

"SELECT * FROM SomeKeySpace WHERE userId IN (?) ALLOW FILTERING"

But then after some research I realized that IN clauses should be avoided especially when passing alot of parameters.

This is what my table looks. Id is the primary key

 id      | date        | content             | userid
---------+-------------+-------------------------+--------
 1427181 | 27-Apr-2018 |           sometext  |   5332

I am trying to retrieve the date and the content filtered by userids. In the attempt that i mentioned above I had retrieved all the userIds from another db and pushed them to an array then i passed it as a parameter.

1 Answer 1

1

This really depends on what other queries you're planning to execute - in Cassandra you need to model data around your queries.

For your specific question, you need either secondary index on userid, and do search (there are also some limitations there), or build second table with composite primary key consisting of userid, date, id - this would be especially useful if you'll have query "Show me all blog posts by this user".

Doing ALLOW FILTERING is generally is not recommended, because it may cause scanning of your whole cluster.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.