Reputation: 75
something I don't understand about querying a dynamoDB table is that it seems necessary to include something like .withKeyConditionExpression("itemId = :v_id")
, but since the partition key uniquely identifies all items in the table, wouldn't you always be searching just one result?
Trying to do something like:
val expression = DynamoDBQueryExpression<PluginItem>()
.withKeyConditionExpression("itemId > 0")
.withFilterExpression("attributes.item_modification_date < :val1")
.withExpressionAttributeValues(eav)
val paginatedResults = queryByExpression(expression)
I'm looking to query and paginate 100,000 items in the table, can anyone point me in the right direction?
Upvotes: 0
Views: 281
Reputation: 637
partition key uniquely identifies all items in the table
so this isn't accurate. It depends on your table design. However, you will get a lot more fexibility if you design a table with a ParitionKey and a Sort Key. That said, back to your statement. A Primary Key not a partition key uniquely identifies an item in the table. A primary key is a combination of ParitionKey + SortKey(also known as Range Key).
Think of each partition as a bucket.
withKeyConditionExpression("itemId > 0")
this won't work. You can't do those kinds of operations on a partition key. However, you can do those kinds of conditions on a sort key.
a video from 2018 - re:Invent that helped me get a better understanding of Dynamo. I have watched that video quite a few times, especially the last 30 to 20mins of it.
Hope that helps. I have only been working with dynamodb for a few months and there is so much more I have to learn.
Upvotes: 1