如何更新DynamoDB中的所有记录? [英] How to update all records in DynamoDB?

查看:186
本文介绍了如何更新DynamoDB中的所有记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是nosql / DynamoDB的新手。

I am new to nosql / DynamoDB.

我有约10000个容器项记录的列表,该记录每6小时更新一次:

I have a list of ~10 000 container-items records, which is updated every 6 hours:

[
   { containerId: '1a3z5', items: ['B2a3, Z324, D339, M413'] },
   { containerId: '42as1', items: ['YY23, K132'] },
   ...
]

(主键= containerId)


  1. 是可以删除表,并用新值重新创建?

  1. Is it viable to just delete the table, and recreate with new values?

还是我应该遍历表中的每个项目新列表,并有条件地更新/写入/删除当前DynamoDB记录(使用batchwrite)?

Or should I loop through every item of the new list, and conditionally update/write/delete the current DynamoDB records (using batchwrite)?


推荐答案

在这种情况下,批量更新是更好的方法。您有两种情况:

For this scenario batch update is better approach. You have 2 cases:


  • 如果只需要更新某些记录,则比批量更新更为有效。您可以扫描整个表,并反复考虑记录并仅更新某些记录。

  • 如果您需要每6小时更新所有记录,则批量更新会更有效,因为如果删除表和重新创建表,这也意味着您必须重新创建索引,但这不是一个非常快速的过程。在重新创建表之后,您仍然必须执行插入操作,与此同时,您必须将所有记录保留在另一个数据库或内存中。

如果需要从具有数千个或更多记录的表中删除所有数据,这比删除通过API删除所有记录要快得多,那么删除整个表是一种好方法。

One scenario where deleting the whole table is a good approach if you need to delete all the data from the table with thousands or more records, than its much faster to recreate table, than delete all the records though API.

您还考虑了其​​他建议,因为您的问题对于DynamoDB而言似乎不是一个好用例。例如,MongoDB和Cassandra支持通过开箱即用的查询进行更新。

And one more suggestion have you considered alternatives, because your problem does not look like a good use-case for DynamoDB. For example MongoDB and Cassandra support update by query out of the box.

这篇关于如何更新DynamoDB中的所有记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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