Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB performance/cost difference between map or separate attributes

Since DynamoDB now supports JSON documents (the map type) and projections into documents, is there a performance or cost difference between storing a map as one attribute vs storing the fields as separate attributes?

For example, I have a table for API access to different sites. Most use a client_id and client_secret, some have an additional field like a server_token, and a few use something else. Is there a difference between storing items with a single map attribute or with multiple attributes?

id | name   | data
———————————————————————————————————————————————————————————————————————
1  | Google | {client_id: XXX, client_secret: XXX}
2  | Uber   | {client_id: XXX, client_secret: XXX, server_token: XXX}

versus

id | name   | client_id | client_secret
————————————————————————————————————————
1  | Google | XXX       | XXX
========================================
id | name | client_id | client_secret | server_token
—————————————————————————————————————————————————————
2  | Uber | XXX       | XXX           | XXX
like image 564
FeifanZ Avatar asked Nov 27 '15 23:11

FeifanZ


People also ask

Which of the following is the fastest way to get an item from DynamoDB?

GetItem – Retrieves a single item from a table. This is the most efficient way to read a single item because it provides direct access to the physical location of the item. (DynamoDB also provides the BatchGetItem operation, allowing you to perform up to 100 GetItem calls in a single operation.)

Where should large attribute values should be stored in relation to DynamoDB?

Storing large attribute values in Amazon S3 As mentioned previously, you can also use Amazon S3 to store large attribute values that cannot fit in a DynamoDB item. You can store them as an object in Amazon S3 and then store the object identifier in your DynamoDB item.

What is the relationship between an attribute item and table in Amazon DynamoDB?

In DynamoDB, tables, items, and attributes are the core components that you work with. A table is a collection of items, and each item is a collection of attributes. DynamoDB uses primary keys to uniquely identify each item in a table and secondary indexes to provide more querying flexibility.


1 Answers

In terms of performance or cost there shouldn't be any difference between using top level attributes vs nesting them under a data attribute.

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.

like image 129
Ryan Fitzgerald Avatar answered Oct 13 '22 20:10

Ryan Fitzgerald