2i for single-result lookup

Nate Lawson nate at root.org
Mon Nov 7 20:59:51 EST 2011

On Nov 7, 2011, at 5:45 PM, Greg Pascale wrote:

> Hi,
> I'm thinking about using 2i for a certain piece of my system, but I'm worried that the document-based partitioning may make it suboptimal.
> The issue is that the secondary fields I want to query over (email and username) are unique, so each will only ever map to one value. Since 2i queries a coverage set, but I'm only ever looking for one result, it's going to be hitting n-1 machines needlessly.
> So, what I'm looking to understand is how much overhead a single-result 2i lookup like this will incur vs. a primary-key lookup, or even vs. search. Search doesn't intuitively feel like the right tool here, but I wonder if it may actually be preferable since it uses term-based partitioning.
> Thanks,

If it's only 2 keys, why not insert each separately? You will double your total number of keys in the db. But both search and 2I are creating extra keys anyway in their private indices, so it has the same or worse effect on total storage as doubling your primary keys. And query efficiency is worse, as you point out.

2I and search are more useful where there's some relationship between the keys, not when they're fully independent as you point out.


More information about the riak-users mailing list