Link or Secondary Indexes?

Kresten Krab Thorup krab at
Thu Mar 29 10:51:13 EDT 2012

It all depends on how you use it. At scale, the number of disk accesses and round trips may be quite different from what you'd expect.

If you "usually" would want to follow the links, then you're probably better off denormalizing the data in Riak so you can get the information you need in fewer round trips and disk reads. I.e. embed the linked to information directly in your objects.  

Ive seen comments here on the list that links are bad if you expect more than ~1000 per object, ... If you need them followed often then you only want max 10 ... Remember that each individual link-following is another disk read.  Secondary indexing scales much better to large numbers, but has the drawback that a query hits 1/N of your vnodes (typically all machines). For many kinds of indexing riak_search is fundamentally a superior solution, but it has some operational drawbacks in recovery from node crashes.

So Either way, a de-normalized "document oriented" or "pre-cooked" data model will perform better. Then secondary indexing or links can be used for more infrequent ad-hoc queries.


On Mar 29, 2012, at 16:29, "Buri Arslon" <buriwoy at> wrote:

> Hi,
> While developing my pet project few questions came to my mind and I decided to consult with you.
> Which of them are more effective for recording relationships: Link or Secondary Indexes?
> 1. Friend relationships: like Facebook friends?
> 2. Followed/follower relationships like in Twitter?
> 3. Member/Club relationship like fanpage in Facebook?
> 4. Like in Facebook?
> Thanks,
> -- buriwoy
> _______________________________________________
> riak-users mailing list
> riak-users at

More information about the riak-users mailing list