If our service is even slightly successful, a user's timeline is going to contain thousands or tens of thousands of status updates. We will, of course, want to show only a few most recent by default and allow the user to paginate through older ones. Fortunately, Cassandra allows us to use the ORDER BY clause in a query that specifies multiple partitions using the IN keyword; under the hood, Cassandra will perform an ordered merge of the rows from the specified partitions.
Let's assume that we only want to show two status updates per page. Accordingly, we'll add the LIMIT and ORDER BY clauses to our query:
SELECT "username", "id", UNIXTIMESTAMPOF("id"), "body" FROM "user_status_updates" WHERE "username" IN ('carol', ...