Say in AWS DynamoDB, I have a table:
ID (Partition key, GSI's Sort Key) OtherAttribute Name (GSI's Partition Key)
0 1/1/2020 Alice
1 2/1/2020 Bob
2 3/1/2020 John
3 4/1/2020 Alice
4 5/1/2020 Bob
5 5/1/2020 Michael
And my GSI projects all attributes of original table.
Now I want to finally get a Set data structure of {"Alice", "Bob", "John", "Michael"}.
How can I achieve this? It seems that Scan operation can not select unique values itself, which means the Scan operation in my case can not get any faster, right? Then after I get a list of all items retrieved, then I need to operate on this list to extract unique values of column Name, is this the only way to do this?
Thus I guess I need to scan the whole table. Here comes another question that is, since my GSI projects all attributes, will there be any difference by scanning GSI or just original table? My goal is certainly to achieve this job as fast as possible.
Could someone give some suggestions?
Thanks!