DynamoDB是否支持AVG,MAX,MIN之类的聚合函数? [英] Does DynamoDB support aggregate functions like AVG, MAX, MIN?

查看:154
本文介绍了DynamoDB是否支持AVG,MAX,MIN之类的聚合函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了DynamoDB文档,并使用 QueryResult 处理示例,我找不到如何在DynamoDB中使用min,max和avg的任何源(我正在使用Java API)。

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).

推荐答案

这些未提供。您可以通过查询或使用过滤器进行扫描并自己计算值来实现这些目标。为了简化一点,您可以使用 Count 参数仅返回该查询/扫描将返回的项目数,而不是实际的项目数。 (请注意,count只返回部分计数-您可能需要对查询/扫描的多个页面中的计数求和。)

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).

或者,您可以维护一个单独的表来存储这些值将随着主表的更新而更新(请注意,保持同步可能很棘手,您必须使用某种形式的事务管理并考虑dynamo的最终一致性模型)。

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).

这篇关于DynamoDB是否支持AVG,MAX,MIN之类的聚合函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆