amazon-web-services - 在AWS DynamoDB中使用batchGetItem与迭代getItem有什么不同的优势吗?

标签 amazon-web-services amazon-dynamodb

来自http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#BatchOperations :
这些批处理 API 作为其他非批处理 DynamoDB 操作的包装器来实现。 BatchGetItem 为批处理中的每个项目调用 GetItem。

并来自: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#CapacityUnitCalculations :
对于 BatchGetItem,批处理中的每个项目都是单独读取的,因此 DynamoDB 首先将每个项目的大小向上舍入到下一个 4 KB,然后计算总大小。结果不一定与所有项目的总大小相同。例如,如果 BatchGetItem 读取 1.5 KB 项目和 6.5 KB 项目,DynamoDB 将计算大小为 12 KB (4 KB + 8 KB),而不是 8 KB (1.5 KB + 6.5 KB)。

那么,与迭代列表并调用 getItem api 相比,使用 batchGetItem api 在响应时间或其他方面有什么优势吗?

最佳答案

是的,响应时间。 BatchGetItem 为 GetItem 并行检索项目,而不是顺序检索项目。但是,还有一些其他可能相关的考虑因素:

  1. 您需要确保您的表设置了适当数量的读取单元;
  2. 检查预期结果 - 您可能无法获得批量请求中的所有项目,因此您可能需要再次请求。

希望这有帮助。

关于amazon-web-services - 在AWS DynamoDB中使用batchGetItem与迭代getItem有什么不同的优势吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34786517/

相关文章:

aws-lambda - Serverless.com/CloudFormation : Properties "Retry attempts", "Maximum age of record"未在 AWS Lambda EventSource 上设置映射到 DynamoDB 流

android - 让监听器知道何时将新项目添加到 DynamoDB

c# - 为什么我无法在 .Net 中使用 AWS SES 接收电子邮件

amazon-web-services - AWS Athena - 使用 SQL 更新表行

amazon-web-services - 云形成: separate cloudformation template of S3 bucket and Lambda

amazon-web-services - 如何在 Elastic Beanstalk 实例上修复 'Health checks failed with these codes: '?

amazon-web-services - DynamoDb 删除不存在的项目不会失败,为什么?

java - 如何在 dynamodb getItem 中应用过滤器

amazon-web-services - DynamoDB Marshal 和 unmarshal golang time.Time 自纪元以来以毫秒为单位

php - 亚马逊 MWS : Errors with new 2013 ListOrders API