0

I have a use-case where I need to query based on a 2i value and retrieve all the Riak objects intstead of only keys. Doing a map-reduce operation for this took quite a long time and more computations.

Is there any other solution for this?

Gaurav
  • 107
  • 1
  • 8
  • Riak does provide the `return_terms` option for 2i queries. So if the data you are interested in was included in the index, you can return that piece directly with the 2i results. – Joe Jun 27 '14 at 23:10
  • @Joe return_terms only the index values matched by the range along with the keys in a search query, for more details see the following [link](http://docs.basho.com/riak/latest/dev/references/http/secondary-indexes/) – Gaurav Jun 28 '14 at 17:18
  • That is true, but I have seen people get creative when they only needed part of the object, like indexing date-email and date-name and date-topic-title in separate indexes so they could return enough with the index query to present to the user for them to select which they wanted to see in full. – Joe Jun 28 '14 at 21:09

1 Answers1

0

Since a 2i search returns a list of matching keys, you can then make multiple parallel requests to fetch the associated objects.

Riak is not like a traditional RDBMS where you try to minimize the number of fetch requests you make. I recommend benchmarking to find an ideal number of parallel requests to maximize performance to fetch objects.

Finally, please ensure that you are using a load balancer between your application and Riak so that these fetch requests are balanced among the nodes in your cluster.

Luke Bakken
  • 8,993
  • 2
  • 20
  • 33
  • Thanks for the suggestion, I already did benchmark on number of parallel requests but results were not satisfactory when number of keys cross 5K and average riak object size being less than 700KB – Gaurav Jun 28 '14 at 17:22