I am doing some tests with dynamodb in local and I have seen a behaviour that I can't explain that leads to a particular question. For the context, I was doing my tests with the nodejs SDK V3 using DynamoDBDocumentClient (an utility that will convert javascript object to dynamodb attributes https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/dynamodb-example-document-client.html).
So I simply noticed in local that when I was calling PutItem with a list of map it was a lot faster (300ms) than when calling with a map of list (4s). List of map (case 1):
{
"L": [
{
"M": {
"Element1": {
"L": [
{
"S": "1"
},
{
"N": "1660964494"
},
{
"S": "1"
}
]
}
}
}, //... more elements continuing here
Map of list (case 2):
{
"M": {
"Element1": {
"L": [
{
"S": "1"
},
{
"N": "1660964550"
},
{
"S": "1"
}
]
},// More and more elements after that...
Also, as expected, depending on the structure of the datas the request will cost more or less capacityUnits. In local for my datas I have: case 1 => 176 CapacityUnits case 2 => 138 CapacityUnits
However since case 1 seems a lot faster than case 2 in local (maybe because of the way dynamodb is storing List and maps) I would like to know if it will be better to use case 2 since it will use less capacityUnits so it means I will pay less I guess. Maybe case 1 is better because there is a cost in dynamodb for the speed of the request? (can't find any documentation on this)
Or maybe it's just a behaviour in local and the speed doesn't correlate with production dynamodb?