0
votes

Let say I have a table with partition key "ID" and range key "Time" with the following items:

ID  | Time | Data
------------------
A   | 1    | abc
A   | 2    | def
B   | 2    | ghi
B   | 3    | jkl

And I want to scan only one item in each partition that has the highest time value in each partition. So the outcome of the scan should look like:

ID  | Time | Data
------------------
A   | 2    | def
B   | 3    | jkl

Is this possible with the DynamoDB's scan feature? (I want to avoid scan all and do such filtering by myself).

1

1 Answers

0
votes

If you want to fetch just a few IDs along with their highest Time, you can query with reverse index, so for every ID, you will have only 1 item read. But for this you need an existing list of IDs.

So for each ID, there will be:

  • 1 query
  • 1 item read

Otherwise, the only way is to scan everything unfortunately.