简体   繁体   English

在DynamoDB表中使用GSI时估算额外的维护成本

[英]Estimating extra maintenance cost when using GSI in a DynamoDB table

I have a Users table in DynamoDB that has a unique hash key username . 我在DynamoDB中有一个用户表,该表具有唯一的哈希键username I want, however, to be able to find a specific user in the most efficient way possible by providing either just the username, or just the email (the email is also unique). 但是,我希望能够通过仅提供用户名或仅提供电子邮件(电子邮件也是唯一的)来以最有效的方式找到特定用户。 I can make the email a global secondary index, but I have a trouble estimating the additional cost of this approach. 我可以使电子邮件成为全局二级索引,但是在估算这种方法的额外成本时遇到了麻烦。 Will using the index to retrieve a user result in two read operations? 使用索引检索用户会导致两次读取操作吗? Or how many operations exactly? 还是到底要进行多少次操作?

Also, I want read and write throughput of the index to equal those of the table (and ideally, scale automatically), can I do that by not providing specific throughput values when I create the index with API, or do I have to provide them? 另外,我希望索引的读写吞吐量等于表的吞吐量(理想情况下会自动缩放),我可以通过使用API​​创建索引时不提供特定的吞吐量值来做到这一点,还是必须提供它们?

The number of read operations you will need to retrieve values from the index will depend on what values you want to read (all of them vs just a subset) and what the projection type for the index is. 从索引中检索值所需的读取操作数将取决于您要读取的值(所有值还是一个子集)以及索引的投影类型是什么。 If the projection is ALL then it only takes 1 read, but it may cost more. 如果投影为ALL,则只需读取1次,但可能会花费更多。 If the projection is KEYS_ONLY you will only get back the table's primary key, then you would have to query the table again by that. 如果投影为KEYS_ONLY,您将只取回表的主键,那么您将不得不再次查询该表。 That takes more than 1 read, but may be cheaper. 这需要读取1次以上,但可能更便宜。 It will all depend on your use cases and usage patterns. 这完全取决于您的用例和使用模式。

See "Attribute Projections" at https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html 请参阅https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html上的 “属性投影”

I think you need to provide the read capacity and write capacity for the index when it is created - it will not inherit any values from the parent table. 我认为您需要在创建索引时提供索引的读取容量和写入容量-它不会从父表继承任何值。 Although if the table is using autoscaling, the autoscaling configuration can be automatically applied to the GSI. 尽管如果表正在使用自动缩放,则可以将自动缩放配置自动应用于GSI。 See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AutoScaling.Console.html#AutoScaling.Console.ExistingTable 参见https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AutoScaling.Console.html#AutoScaling.Console.ExistingTable

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

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