Hi Erez, Don't know how many friends a user in your system is likely to have, but are they likely to have received so many messages from friends that you can't sort it in your client app?
See: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#sort(java.util.List) Assuming the user has 10,000 friends (I'm sure I don't even know 10,000 people :) with Java's Collections.sort which guarantees performance of O(n log(n)) let's say it takes 1ms to process each item, you're looking at 40,000ms to do a sort plus a little overhead to avoid the O( n2 log(n)) - that's 40 seconds to sort for 10,000 friends... On Facebook I have 363 friends that's 929ms + overhead, i.e. around a second. Apparently the average Facebook user has 130 friends: http://www.facebook.com/press/info.php?statistics So I can't imagine the sort exceeding much more than a second or so except for the most popular users - in practice I would hope sub-second easily. Does that help? Or is there something special happening in your system? Cheers, Chris On 24 March 2010 20:36, Erez Efrati <ere...@gmail.com> wrote: > Hi, > > I can't figure out how to use model the following using column family and > the way the columns are sorted (by their name). > > Lets say I have a list of users and for each user I wish to display a list > of all the friends he has ordered by the number of messages they sent him so > far (desc from most to least). > > I can't see how this is going to work since the columns sorting is always > by the name of the column and not its value. I thought of having a row for > each user and the columns will be the friends that email him. But the column > name needs to be the number of messages to be sorted and the value will be > the friend's user ID. But then, when a friend is sending a message to > another user how do I increment his count of message he sent so far to that > user? > > How can I model this with Cassandra? Is it possible? > > Thanks in advance, > > Erez Efrati >