I have a DynamoDB table with two GSI:
GSI 1
- hash key:
studentGroup
- sort key:
mathScore
GSI 2
- hash key:
studentGroup
- sort key:
scienceScore
When I scan the table with filter studentGroup = 1
, does DynamoDB return the results in the order of mathScore
or scienceScore
?
Is there any way to specify which attribute (or which GSI) to be used for sorting?
If not possible, what's the best practice to design GSI to sort by an attribute that the application side can choose?
I tried from the DynamoDB management console, but it seems no way to specify which index to be used for scanning.