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

查看:30
本文介绍了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).

或者,您可以维护一个单独的表,在主表更新时为您存储这些值(请注意,保持同步可能很棘手,您必须使用某种形式的事务管理并考虑到发电机的最终一致性模型).

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天全站免登陆