I’m trying to play with Aerospike. I have mostly a MongoDB background, and I know people are always, “Choose The Best Database for Your Application”, however I’m more of a “Try to use what’s cheapest first” kind of guy. I know that it can be simple for an ad-server that needs simple impression/click/conversion data, but I’m thinking more “complex” data.
So, upon playing with it, I don’t see any documentation on specific data modeling for specific use-cases. Feel free to point that any scenario I’m asking about should not belong in Aerospike and I’ll run away
Users & Profiles
A JSON user would look like: { “email”: “john@doe.com”, “firstName”: “John”, “password”: “secure” …, …, “friends”: [“mary@jane.com”, …]}
Some examples show that I can look the user up via key “john@doe.com” (typical key/value stuff). But how can I get a “paginated” list of:
A) The user’s sorted by newest to oldest (& visa-versa) (assuming there are millions of friends)
B) The user’s friends sorted by newest to oldest (& visa-versa) (assuming a user can have millions of friends)
Other sorting questions:
Sort by keys
Sort by BIN values
All the above + limit/skip
Also, what’s the possible performance of these (on a large scale).
The user’s sorted by newest to oldest (& visa-versa) (assuming there are millions of friends)
This would need you to add create-timestamp bin and have secondary index on it. Secondary index query over time range and processing at client side should give you sorted list.
The user’s friends sorted by newest to oldest (& visa-versa) (assuming a user can have millions of friends)
This would need you to add friends bin (of type large list to be able to store million of them) with timestamp key in large list. Large list returns data in key sorted order, which in your case will be time sorted order.
Sort by keys
Aeropike primary key lookup is hash based. To get access in sorted order you need store key in bin and create secondary index on it. Also currently we do not support (ofcourse in roadmap) range query on string, so it has to be integer key.
Sort by BIN values
Same as above.
All the above + limit/skip
We do not have skip and limit API currently supported. When working with range query you should be able to request range of data.
Finally your record would look something like
Record → key-bin , Create-timestamp bin , friends bin, other bins …
With secondary index on key-bin and create-timestamp bin