Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does DynamoDB support aggregate functions like AVG, MAX, MIN?

I tried DynamoDB docs and work with example using QueryResult, I couldn't find any source how to using min, max and avg in DynamoDB (I'm using Java API).

like image 891
Damith Ganegoda Avatar asked Oct 10 '14 11:10

Damith Ganegoda


1 Answers

These are not provided. You'd implement these by either doing a query or scan with a filter, and calculating the values yourself. To simplify things a bit, you can use the Count parameter to return only the count of items that would be returned by that query/scan instead of the actual items. (Note that count only returns a partial count - you may need to sum counts across multiple pages of queries/scans).

Alternatively, you can maintain a separate table that stores these values for you as the main tables are updated (note this can be tricky to keep in sync, you'll have to use some form of transaction management and take into account dynamo's eventual consistency model).

like image 90
Krease Avatar answered Sep 19 '22 10:09

Krease