0
votes

I'd like a list of all the primary sort keys from a table with a composite primary key (partition key and sort key). The table contains many partitions.

2

2 Answers

1
votes

As the other answer mentions, Scan() would be your only solution over the table itself...

This would not be fast or cheap on a large table.

If you need this regularly, consider a couple other options:

  1. using a trigger (Dynamo streams + lambda) to track key values on insert
  2. a Global secondary index with a dummy hash key value, and sort key of the actual keys
0
votes

You will need to use the scan, sort the result and remove the duplicates.

It would be wise to also use the ProjectionExpression property of the scan to limit the response to only the partition and sort keys.