I have a DynamoDB table which looks like this:
[id] [datetime] [name] [reasonForVisit] [__typename]
[id]
is the simple primary key for the table
[__typename]
is an attribute that has the same value for all items in the table
The table has become very big. I want to be able to filter the data by range in terms of datetime
. I have 2 quickly implementable options on my mind, but am unsure if it would make much of a difference in terms of costs.
- SCAN the whole table and then filter by datetime (as dynamodb doesn't allow filtering before scan)
- Create a GSI (partitionKey: __typename, sortKey: datetime) and QUERY by the fixed __typename partition and filter by datetime sort key e.g. between 10/8/10 and 10/11/10.
So, my question is, since my partition key will be the same for each item, hence one big partition, I'm not sure if when QUERYing with a filter, does it still result in reading the whole table (similar to SCAN) or does it know to efficiently start reading from an item based on the filter?