Fei*_*anZ 4 database-design nosql amazon-dynamodb
由于 DynamoDB 现在支持 JSON 文档(地图类型)和到文档的投影,将地图存储为一个属性与将字段存储为单独的属性之间是否存在性能或成本差异?
例如,我有一个用于访问不同站点的 API 的表。大多数使用 aclient_id和client_secret,有些有一个额外的字段,如 a server_token,还有一些使用其他字段。存储具有单个地图属性或具有多个属性的项目之间有区别吗?
id | name | data
———————————————————————————————————————————————————————————————————————
1 | Google | {client_id: XXX, client_secret: XXX}
2 | Uber | {client_id: XXX, client_secret: XXX, server_token: XXX}
Run Code Online (Sandbox Code Playgroud)
相对
id | name | client_id | client_secret
————————————————————————————————————————
1 | Google | XXX | XXX
========================================
id | name | client_id | client_secret | server_token
—————————————————————————————————————————————————————
2 | Uber | XXX | XXX | XXX
Run Code Online (Sandbox Code Playgroud)
小智 6
在性能或成本方面,使用顶级属性与将它们嵌套在data属性下应该没有任何区别。
However, as of today DyanmoDB does not support creating secondary indexes on nested attributes. Say in the future you needed to query this table by client_id, if you nested that attribute then you wouldn't be able to add a global secondary index on that attribute.
| 归档时间: |
|
| 查看次数: |
659 次 |
| 最近记录: |