简体   繁体   English

如何从 dynamodb 中批量删除所有没有 TTL 的记录?

[英]How bulk delete all records without TTL from dynamodb?

As the question says, I have about 200million data records in a table in dynamoDB.正如问题所说,我在 dynamoDB 的一个表中有大约 2 亿条数据记录。 I am writing a script in nodejs that needs to delete all data without a TTL.我正在用 nodejs 编写一个脚本,需要在没有 TTL 的情况下删除所有数据。 I have 3 ideas for this, and I am curious on thoughts about how I should go about doing this on so many records.我对此有 3 个想法,我很好奇我应该如何 go 在如此多的记录上执行此操作。

  1. batchWrite, this option I would scan then paginate through the whole table, deleting each record as it meets the condition of not currently having a ttl batchWrite,我会扫描这个选项,然后对整个表进行分页,删除每条记录,因为它满足当前没有 ttl 的条件

  2. push all records that dont have a ttl to a new table and then delete that table all at once将所有没有 ttl 的记录推送到新表,然后立即删除该表

  3. set a ttl for records that dont have one, but I cant find any information if this is even a thing or if I can somehow bulk add a ttl to all records without one为没有记录的记录设置一个 ttl,但我找不到任何信息,如果这甚至是一件事,或者如果我可以以某种方式批量添加一个 ttl 到所有没有记录的记录

Any information is helpful, please let me know how I can go about doing this!任何信息都有帮助,请让我知道如何 go 做这件事! Thank you谢谢

I would go with option 1 -我会用选项 1 go -

Check Parallel Scan doc, pasting some information here.检查并行扫描文档,在此处粘贴一些信息。

Segment — A segment to be scanned by a particular worker. Segment — 由特定 worker 扫描的段。 Each worker should use a different value for Segment.每个 worker 都应该为 Segment 使用不同的值。
TotalSegments — The total number of segments for the parallel scan. TotalSegments — 并行扫描的段总数。 This value must be the same as the number of workers that your application will use.该值必须与您的应用程序将使用的工作人员数量相同。

Here, each segment will work on each partition DDB has made on your table.在这里,每个段将在 DDB 在您的表上创建的每个分区上工作。 Each partition in DDB is of 10GB. DDB 中的每个分区都是 10GB。 With scanning/ read made faster, we can now perform deletes using BatchWrites .随着扫描/读取速度的加快,我们现在可以使用BatchWrites执行删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM