0

I am working on a social networking project with cassandra. Users can subscribe to a profile and have access to the list of people who have subscribed to that same profile. My goal is to retrieve in a table called user_follows the list of people subscribed to a profile.

CREATE TABLE users_follows (to_id text, from_id text, followed_at timestamp, PRIMARY KEY(to_id, from_id))

The problem is that some profiles can have thousands of subscribers and I don't want to get them all at once. That's why I'd like to get the list in increments of 20 depending on how far down the user goes. My problem is that I can't see how to retrieve the other parts of the list after the first select because Cassandra always returns the same users.

SELECT * FROM users_follows where to_id = 'xxxxx'

A possible solution was to sort with a timestamp but in case I want to retrieve the list of people to whom a user is subscribed (the reverse query) this would not work. One solution would be to use materialized views but I'm not sure that it would be very optimal given the size of the table. Or to create a different table, one user_follows and another user_followers, but I don't think this is very recommended....

Jesver
  • 83
  • 1
  • 6
  • any reason not to use query pagination? – Andrew May 21 '22 at 20:30
  • Does this answer your question? [Results pagination in Cassandra (CQL)](https://stackoverflow.com/questions/26757287/results-pagination-in-cassandra-cql) – PM 77-1 Jun 02 '22 at 18:49

0 Answers0