dynamodb中的查询是否保留插入顺序? [英] Is insert order preserved on queries in dynamodb?

查看:70
本文介绍了dynamodb中的查询是否保留插入顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正计划将dynamodb用作聊天记录的数据存储。如果我未声明范围顺序并仅设置 ScanIndexForward = false ,对它执行的任何查询中都会保留插入顺序吗?

I'm planning on using dynamodb as a data store for chat logs. Is insert order preserved in any queries that I do against it if I don't state a range order and just set ScanIndexForward = false?

我只想查询给定哈希值的尾部 100条消息,并希望确保它们根据记录的时间顺序降序返回

I would just want to query for the tail 100 messages for a given hash and want to make sure they are coming back chronologically descending based on when the record was inserted.

推荐答案

否,项目始终按范围键排序(并且仅在同一哈希键内)。

No, items are always ordered by range key (and only within the same hash key).

对于带有给定哈希键,DynamoDB将这些项存储在一起,并按范围键排序。

将插入时间作为范围键可能是最简单的(如果需要,可以作为辅助索引。)

It would probably be easiest to make insertion time the range key (possibly as a secondary index if needed).

或者,您可以使用 DynamoDB流以跟踪其他地方的前100个更新。

Alternatively, you could use DynamoDB Streams to keep track of the last 100 updates somewhere else.

这篇关于dynamodb中的查询是否保留插入顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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