【问题标题】:Is there a difference between DynamoDB Local Secondary Index vs Global Secondary Index if the partition key is the same?如果分区键相同,DynamoDB 本地二级索引与全局二级索引之间有区别吗?
【发布时间】:2021-03-14 03:07:33
【问题描述】:

所以目前我有一张桌子


playerName:String  (Partition)
playerAge:Number   (Sort)
player_str_dex_int_luck:String (Local Secondary Index Sort Key)

我想向我的表 player_dex_str_int_luck:String 添加一个键以进行排序,同时将 playerName 作为我的分区键。

我必须为此使用 GSI,因为您无法在创建表后创建 LSI。由于我将 GSI 的分区键与原始表的分区键保持一致,因此 GSI 和 LSI 之间有什么区别吗?

【问题讨论】:

    标签: nosql amazon-dynamodb dynamodb-queries


    【解决方案1】:

    LSI——无需额外费用,自动拥有记录的所有属性。自动与表一致。

    GSI - 额外费用,必须在 GSI 中指定您想要的属性。对于任何其他人,必须阅读表格。 “以最终一致的方式更新。”

    但是,使用 GSI 而不是 LSI 的一个好处是,没有 LSI 的表可以有partitions larger than 10GB

    项目集合大小限制
    任何项目集合的最大大小是 10 GB。此限制不适用于没有本地辅助的表 索引。只有具有一个或多个本地二级索引的表才是 受影响。

    【讨论】:

    • 因此,如果我指定将所有属性投影到 GSI 并且不打算使用强一致性读取,那么除了使用 GSI 而不是 LSI 的成本之外,没有其他缺点吗?
    猜你喜欢
    • 2018-11-01
    • 1970-01-01
    • 2018-10-09
    • 2016-09-17
    • 1970-01-01
    • 2021-03-30
    • 1970-01-01
    • 1970-01-01
    • 2015-11-03
    相关资源
    最近更新 更多