Reputation: 1696
I m porting a CosmosDB data model to DynamoDB. The objects look like that:
{ pk: "mypk", id: "myid", keywords: [ "lac", "sun", "nature" ] }
In CosmosDB I can make a query to the items of the list and hit an index, resulting in a fast and efficient query
SELECT * FROM c where c.pk = "mypk" and ARRAY_CONTAINS(c.keywords, "sun")
In DynamoDB sort keys doesn't support list, how do you deal with queries on list? Should I go with a composite key something like "#lac#sun#nature" and do something like that in PartiQL:
SELECT * FROM "myTable" WHERE "pk"='mypk' AND contains("keywords", '#sun')
Or should I change the data design to allow efficient query but how?
Upvotes: 0
Views: 334
Reputation: 19883
The Query in DynamoDB is still efficient unless you have a large amount of data that shares the same PK.
A composite key will not work as there is no contains
function for a key.
I suggest you test your efficiency by using ReturnConsumedCapacity
flag to see how much capacity you consume doing it the way it is. I'm guessing it's pretty efficient.
Upvotes: 0