How to get distinct count on dynamodb on billion objects?

amazon-dynamodb, key-value

Solution

In case you need counters it's better to use the AtomicCounters (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithDDItems.html). In your case, DynamoDB doesn't support out of the box keys composed out of 3 attributes, unless you concatenate them, so the option would be to create a redundant table where the key is the concatenation of those 3 attributes and each you manage those objects, also update the AtomicCounter (add, delete, update - not needed actually).

Then you just query the counter, avoiding scans. So, it's space complexity to gain speed of retrieving data.

Problem

What is the most efficient way to get a number of how many distinct objects is stored in mine dynamodb? Such as my objects have ten properties and I want to get a distinct count based on 3 properties.

Original source